#87431 - 2002-08-23 05:06 PM
DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I'm using 4.11b and I'm having a problem opening an access DB.
code:
$DATABASE = "\\a06\logon\inventory\inventory.mdb" $DSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DATABASE" $Connection = CreateObject("ADODB.Connection") ? @error @serror $Command = CreateObject("ADODB.Command") ? @error @serror $Recordset = CreateObject("ADODB.Recordset") ? @error @serror ? "inventory $Connection" if $Connection ? @error @serror "I'm in" ;Check for connection object $Connection.ConnectionString = $DSN
generates
code:
... 0The operation completed successfully. 0The operation completed successfully. 0The operation completed successfully. inventory ...
it never validates the $connection
Any Ideas??
|
Top
|
|
|
|
#87432 - 2002-08-23 05:22 PM
Re: DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
more detail...
code:
$DATABASE = "\\a06\logon\inventory\inventory.mdb" $DSN = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DATABASE" $Connection = CreateObject("ADODB.Connection") $Command = CreateObject("ADODB.Command") $Recordset = CreateObject("ADODB.Recordset") ; if $Connection ;Check for connection object $Connection.ConnectionString = $DSN $Connection.Open() ;Open connection to database ? @error @serror $Command.ActiveConnection = $Connection $Recordset.CursorType = 3 $Recordset.LockType = 3 $Recordset.ActiveCommand = $Command
? @error @serror $Command.CommandText = "SELECT * FROM [tbl_Users] WHERE NTAccount='@userid'" $Recordset.Open($Command) ? @error @serror If $Recordset.RecordCount < 1 $Recordset.AddNew $Recordset.Fields("NTAccount").Value = @USERID $Recordset.Fields("FirstName").Value = $firstname $Recordset.Fields("LastName").Value = $lastname $Recordset.Fields("OrgCode").Value = $OrgCode $Recordset.Fields("PositionNumber").Value = $positionnum $Recordset.Fields("PhoneNumber").Value = $phoneno $Recordset.Fields("RoomNumber").Value = $roomno $Recordset.Fields("Office").Value = "Area$area" $Recordset.Update ? @error @serror endif $Recordset.Close()
returns
code:
... 0The operation completed successfully. 0The operation completed successfully. -2147352567COM exception error "Open" (ADODB.Recordset - The connection cannot b e used to perform this operation. It is either closed or invalid in this context .) [-2147352567/80020009] ...
|
Top
|
|
|
|
#87434 - 2002-08-23 05:35 PM
Re: DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
Top
|
|
|
|
#87437 - 2002-08-23 06:42 PM
Re: DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
under 4.02 this works fine but fails under 4.11b
code:
$DATABASE = "$logon\inventory\inventory.mdb" $Connection = CreateObject("ADODB.Connection") $Connection.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=$DATABASE" $Connection.Open() if not @error ;Check for connection object $Command = CreateObject("ADODB.Command") $Command.ActiveConnection = $Connection $Recordset = CreateObject("ADODB.Recordset") $Recordset.CursorType = 3 $Recordset.LockType = 3 $Recordset.ActiveCommand = $Command
$Command.CommandText = "SELECT * FROM [tbl_Users] WHERE NTAccount='@userid'" $rc=$Recordset.Open($Command) ? @serror If $Recordset.RecordCount < 1 $Recordset.AddNew $Recordset.Fields("NTAccount").Value = @USERID $Recordset.Fields("FirstName").Value = $firstname $Recordset.Fields("LastName").Value = $lastname $Recordset.Fields("OrgCode").Value = $OrgCode $Recordset.Fields("PositionNumber").Value = $positionnum $Recordset.Fields("PhoneNumber").Value = $phoneno $Recordset.Fields("RoomNumber").Value = $roomno $Recordset.Fields("Office").Value = "Area$area" $Recordset.Update
it fails at line before the @error statement with.
COM exception error "Open" (ADODB.Recordset - The connection cannot be used to perform this operation. It is either closed or invalid in this context.) [-2147352567/80020009]
|
Top
|
|
|
|
#87439 - 2002-08-26 08:45 PM
Re: DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
no change with 4.11 final...
arrgggghhhhh
|
Top
|
|
|
|
#87440 - 2002-08-26 11:01 PM
Re: DB open problem...
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
I found this on the MS web site
What are all these other parameters?
objRecordset.Open "SELECT * FROM Hardware" , objConnection, adOpenStatic, adLockOptimistic
|
Top
|
|
|
|
#87442 - 2002-12-06 07:08 PM
Re: DB open problem...
|
FourEyes
Lurker
Registered: 2002-12-06
Posts: 1
Loc: PORTUGAL
|
Donīt know if you solved that recordset problem...but if not try this:
change your connectionstring to: Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=$db
It worked for me!!
_________________________
Work smarter, not harder...
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
0 registered
and 259 anonymous users online.
|
|
|