Hello; i am studing vbscrip but my office ask me if i can write a script.
In particular i need a script for update a field in a access database with
the current day. How can help me ?


Bye BYE THanks

Re: Update Access File by Nathan

Nathan
Sat Jan 21 14:18:00 CST 2006

You'll want to use VBA or ADO. I not an expert yet but ADO seems to me
to be the better way to go. I don't have any code samples for you but a
good reference site to check out is http://www.devguru.com/home.asp or
goto
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_dataaccess.asp


Re: Update Access File by Donato

Donato
Sat Jan 21 14:21:27 CST 2006

I am studing and i am unable to replay( VBA or ADO ); i need an example so i
can study and understand

"Nathan" <support@iccs1.com> ha scritto nel messaggio
news:1137874680.338507.53960@g14g2000cwa.googlegroups.com...
> You'll want to use VBA or ADO. I not an expert yet but ADO seems to me
> to be the better way to go. I don't have any code samples for you but a
> good reference site to check out is http://www.devguru.com/home.asp or
> goto
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_dataaccess.asp
>



Re: Update Access File by Nathan

Nathan
Sat Jan 21 14:42:56 CST 2006

I found some code I was playing a while ago.

Dim Conn, dbPath
dim firstName(), lastName()
dbPath = "c:\ca.mdb"
Set Conn = CreateObject("ADODB.Connection")
Set Rs1 = CreateObject("ADODB.Recordset")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
Source = "SELECT * FROM tblEmployee"
Rs1.cursorType = 1
Rs1.Open Source, Conn,,,adCmdTable
Rs1.MoveLast
msgBox (Rs1.RecordCount)
Rs1.MoveFirst

i=0
do while rs1.eof = false


redim preserve firstName(i)
redim preserve lastName(i)
firstName(i) = Rs1.Fields("empFirstName")
lastName(i) = Rs1.Fields("empLastName")
fName = firstName(i)
lName = lastName(i)
i=i+1
msgBox (fName & " " & lName)

Rs1.moveNext
Loop

You may want to look up the different types of cursorType. I got
tripped up on that one for a while.

Hope this helps.


Re: Update Access File by Donato

Donato
Sun Jan 22 04:32:22 CST 2006

ok your script working if i wanto read some date from a access database; but
if i want to modify some date i don't work. i have modificate the scrit bu i
donìt work can help me :

the script that i have modificate is this :

-------------------------------------------------------------------------

Dim Conn, dbPath
dim firstName(), lastName()
dbPath = "c:\download.mdb"
Set Conn = CreateObject("ADODB.Connection")
Set Rs1 = CreateObject("ADODB.Recordset")
Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
Source = "SELECT * FROM tblUsers"
Rs1.cursorType = 1
Rs1.Open Source, Conn,,,adCmdTable
Rs1.MoveLast
msgBox (Rs1.RecordCount)
Rs1.MoveFirst
i=0
do while rs1.eof = false
redim preserve firstName(i)
redim preserve lastName(i)
firstName(i) = Rs1.Fields("username")
lastName(i) = Rs1.Fields("password")
fName = firstName(i)
lName = lastName(i)
i=i+1
msgBox (fName & " " & lName)
Rs1.moveNext
Loop
Rs1.MoveFirst

Rs1.Fields("username")=fname + fname
Rs1.Fields("password")=lname +lname
rs1.update

conn.close

----------------------------------------------------------------------------
--


help me to find why i don't work



"Nathan" <support@iccs1.com> ha scritto nel messaggio
news:1137876176.446156.226360@z14g2000cwz.googlegroups.com...
> I found some code I was playing a while ago.
>
> Dim Conn, dbPath
> dim firstName(), lastName()
> dbPath = "c:\ca.mdb"
> Set Conn = CreateObject("ADODB.Connection")
> Set Rs1 = CreateObject("ADODB.Recordset")
> Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
> Source = "SELECT * FROM tblEmployee"
> Rs1.cursorType = 1
> Rs1.Open Source, Conn,,,adCmdTable
> Rs1.MoveLast
> msgBox (Rs1.RecordCount)
> Rs1.MoveFirst
>
> i=0
> do while rs1.eof = false
>
>
> redim preserve firstName(i)
> redim preserve lastName(i)
> firstName(i) = Rs1.Fields("empFirstName")
> lastName(i) = Rs1.Fields("empLastName")
> fName = firstName(i)
> lName = lastName(i)
> i=i+1
> msgBox (fName & " " & lName)
>
> Rs1.moveNext
> Loop
>
> You may want to look up the different types of cursorType. I got
> tripped up on that one for a while.
>
> Hope this helps.
>



Re: Update Access File by Dave

Dave
Sun Jan 22 09:01:08 CST 2006

Give this a go.

Const adOpenDynamic = 2
Const adLockOptimistic = 3

Dim cnn, dbPath
dbPath = "c:\data\access\test1.mdb"
Set cnn = CreateObject("ADODB.Connection")
Set Rs1 = CreateObject("ADODB.Recordset")
cnn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
strSQL = "SELECT * FROM tblUsers"
rs1.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
rs1.AddNew
Rs1.Fields("username")= "Dave"
Rs1.Fields("password")= "zzz"
rs1.update
cnn.close


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Donato P" wrote:
| ok your script working if i wanto read some date from a access database;
but
| if i want to modify some date i don't work. i have modificate the scrit bu
i
| donìt work can help me :
|
| the script that i have modificate is this :
|
| -------------------------------------------------------------------------
|
| Dim Conn, dbPath
| dim firstName(), lastName()
| dbPath = "c:\download.mdb"
| Set Conn = CreateObject("ADODB.Connection")
| Set Rs1 = CreateObject("ADODB.Recordset")
| Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
| Source = "SELECT * FROM tblUsers"
| Rs1.cursorType = 1
| Rs1.Open Source, Conn,,,adCmdTable
| Rs1.MoveLast
| msgBox (Rs1.RecordCount)
| Rs1.MoveFirst
| i=0
| do while rs1.eof = false
| redim preserve firstName(i)
| redim preserve lastName(i)
| firstName(i) = Rs1.Fields("username")
| lastName(i) = Rs1.Fields("password")
| fName = firstName(i)
| lName = lastName(i)
| i=i+1
| msgBox (fName & " " & lName)
| Rs1.moveNext
| Loop
| Rs1.MoveFirst
|
| Rs1.Fields("username")=fname + fname
| Rs1.Fields("password")=lname +lname
| rs1.update
|
| conn.close
|
| ----------------------------------------------------------------------------
| --
|
|
| help me to find why i don't work



Re: Update Access File by Donato

Donato
Sun Jan 22 11:01:19 CST 2006

thank your for your help ; but now i must modify the script so :

- i should add 1 to a numeric filed if a files are present on my hard disk;
il the file are present and i add 1 to the filed the scrit must be stop also
the script must run


"Dave Patrick" <DSPatrick@nospam.gmail.com> ha scritto nel messaggio
news:udm2xR2HGHA.3000@TK2MSFTNGP14.phx.gbl...
> Give this a go.
>
> Const adOpenDynamic = 2
> Const adLockOptimistic = 3
>
> Dim cnn, dbPath
> dbPath = "c:\data\access\test1.mdb"
> Set cnn = CreateObject("ADODB.Connection")
> Set Rs1 = CreateObject("ADODB.Recordset")
> cnn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
> strSQL = "SELECT * FROM tblUsers"
> rs1.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
> rs1.AddNew
> Rs1.Fields("username")= "Dave"
> Rs1.Fields("password")= "zzz"
> rs1.update
> cnn.close
>
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
> "Donato P" wrote:
> | ok your script working if i wanto read some date from a access database;
> but
> | if i want to modify some date i don't work. i have modificate the scrit
bu
> i
> | donìt work can help me :
> |
> | the script that i have modificate is this :
> |
>
| -------------------------------------------------------------------------
> |
> | Dim Conn, dbPath
> | dim firstName(), lastName()
> | dbPath = "c:\download.mdb"
> | Set Conn = CreateObject("ADODB.Connection")
> | Set Rs1 = CreateObject("ADODB.Recordset")
> | Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
> | Source = "SELECT * FROM tblUsers"
> | Rs1.cursorType = 1
> | Rs1.Open Source, Conn,,,adCmdTable
> | Rs1.MoveLast
> | msgBox (Rs1.RecordCount)
> | Rs1.MoveFirst
> | i=0
> | do while rs1.eof = false
> | redim preserve firstName(i)
> | redim preserve lastName(i)
> | firstName(i) = Rs1.Fields("username")
> | lastName(i) = Rs1.Fields("password")
> | fName = firstName(i)
> | lName = lastName(i)
> | i=i+1
> | msgBox (fName & " " & lName)
> | Rs1.moveNext
> | Loop
> | Rs1.MoveFirst
> |
> | Rs1.Fields("username")=fname + fname
> | Rs1.Fields("password")=lname +lname
> | rs1.update
> |
> | conn.close
> |
>
| --------------------------------------------------------------------------
--
> | --
> |
> |
> | help me to find why i don't work
>
>



Re: Update Access File by Dave

Dave
Sun Jan 22 11:06:45 CST 2006

Sorry but I don't know what this means.

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Donato P" wrote:
| thank your for your help ; but now i must modify the script so :
|
| - i should add 1 to a numeric filed if a files are present on my hard
disk;
| il the file are present and i add 1 to the filed the scrit must be stop
also
| the script must run



Re: Update Access File by Donato

Donato
Sun Jan 22 15:42:22 CST 2006

So I must check if a file is present on my hard disk. in thi case i must add
one to a field



"Dave Patrick" <DSPatrick@nospam.gmail.com> ha scritto nel messaggio
news:Oah59X3HGHA.216@TK2MSFTNGP15.phx.gbl...
> Sorry but I don't know what this means.
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
> "Donato P" wrote:
> | thank your for your help ; but now i must modify the script so :
> |
> | - i should add 1 to a numeric filed if a files are present on my hard
> disk;
> | il the file are present and i add 1 to the filed the scrit must be stop
> also
> | the script must run
>
>



Re: Update Access File by Dave

Dave
Sun Jan 22 16:07:20 CST 2006

Const adOpenDynamic = 2
Const adLockOptimistic = 3

Dim cnn, dbPath
dbPath = "c:\data\access\test1.mdb"
Set cnn = CreateObject("ADODB.Connection")
Set Rs1 = CreateObject("ADODB.Recordset")
cnn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath

filecount = 10

strSQL = "SELECT myfilecount, mydate " _
& "FROM tblfiledata " _
& "WHERE (((mydate)=#" & Date & "#)) "

rs1.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
If rs1.EOF = False Then
rs1.Fields("myfilecount")= filecount
Else
rs1.AddNew
rs1.Fields("myfilecount")= filecount
rs1.Fields("mydate") = Date
End If
rs1.update
cnn.close





--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Donato P" <donatopalla@tiscalinet.it> wrote in message
news:43d3fbd7$0$343$5fc30a8@news.tiscali.it...
| So I must check if a file is present on my hard disk. in thi case i must
add
| one to a field
|
|
|
| "Dave Patrick" <DSPatrick@nospam.gmail.com> ha scritto nel messaggio
| news:Oah59X3HGHA.216@TK2MSFTNGP15.phx.gbl...
| > Sorry but I don't know what this means.
| >
| > --
| >
| > Regards,
| >
| > Dave Patrick ....Please no email replies - reply in newsgroup.
| > Microsoft Certified Professional
| > Microsoft MVP [Windows]
| > http://www.microsoft.com/protect
| >
| > "Donato P" wrote:
| > | thank your for your help ; but now i must modify the script so :
| > |
| > | - i should add 1 to a numeric filed if a files are present on my hard
| > disk;
| > | il the file are present and i add 1 to the filed the scrit must be
stop
| > also
| > | the script must run
| >
| >
|
|



Re: Update Access File by Donato

Donato
Mon Jan 23 01:23:22 CST 2006

Thank but I must add a new record only if on my hard disk there is the files
named "rassegna.pdf". Can you modify the scritp ?

BU Bye adn thanks


"Dave Patrick" <DSPatrick@nospam.gmail.com> ha scritto nel messaggio
news:uRhh7$5HGHA.240@TK2MSFTNGP11.phx.gbl...
> Const adOpenDynamic = 2
> Const adLockOptimistic = 3
>
> Dim cnn, dbPath
> dbPath = "c:\data\access\test1.mdb"
> Set cnn = CreateObject("ADODB.Connection")
> Set Rs1 = CreateObject("ADODB.Recordset")
> cnn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath
>
> filecount = 10
>
> strSQL = "SELECT myfilecount, mydate " _
> & "FROM tblfiledata " _
> & "WHERE (((mydate)=#" & Date & "#)) "
>
> rs1.Open strSQL, cnn, adOpenDynamic, adLockOptimistic
> If rs1.EOF = False Then
> rs1.Fields("myfilecount")= filecount
> Else
> rs1.AddNew
> rs1.Fields("myfilecount")= filecount
> rs1.Fields("mydate") = Date
> End If
> rs1.update
> cnn.close
>
>
>
>
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
> "Donato P" <donatopalla@tiscalinet.it> wrote in message
> news:43d3fbd7$0$343$5fc30a8@news.tiscali.it...
> | So I must check if a file is present on my hard disk. in thi case i must
> add
> | one to a field
> |
> |
> |
> | "Dave Patrick" <DSPatrick@nospam.gmail.com> ha scritto nel messaggio
> | news:Oah59X3HGHA.216@TK2MSFTNGP15.phx.gbl...
> | > Sorry but I don't know what this means.
> | >
> | > --
> | >
> | > Regards,
> | >
> | > Dave Patrick ....Please no email replies - reply in newsgroup.
> | > Microsoft Certified Professional
> | > Microsoft MVP [Windows]
> | > http://www.microsoft.com/protect
> | >
> | > "Donato P" wrote:
> | > | thank your for your help ; but now i must modify the script so :
> | > |
> | > | - i should add 1 to a numeric filed if a files are present on my
hard
> | > disk;
> | > | il the file are present and i add 1 to the filed the scrit must be
> stop
> | > also
> | > | the script must run
> | >
> | >
> |
> |
>
>



Re: Update Access File by Dave

Dave
Mon Jan 23 19:52:23 CST 2006

This link should cover that.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/a0d26be0-9447-4bf1-849e-97cad45cc805.asp

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Donato P" wrote:
| Thank but I must add a new record only if on my hard disk there is the
files
| named "rassegna.pdf". Can you modify the scritp ?
|
| BU Bye adn thanks