|
-
Jun 18th, 2003, 02:33 PM
#1
Thread Starter
Junior Member
Recordset problem
I am creating a DB and table etc. on the fly but in the function that I ma testing to see if the user is in the DB it bombs out! It throws an error: "Object variable or block varialbe not set"
Any ideas?
'Creating DB on the fly......
Dim cat As New ADOX.Catalog
'create an Access 97 Database
cat.Create "Provider=Microsoft.Jet.OLEDB.3.51;" & "Data Source=" & App.Path & ".\mydata.mdb"
'DB is locked until cat object is released
Set cat = Nothing
'
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim sSql As String
'Open connection to the new db
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & App.Path & ".\mydata.mdb;Persist Security Info=false"
con.Open
'run Sql query to create table
Set cmd = New ADODB.Command
cmd.ActiveConnection = con
sSql = "CREATE TABLE Students (LoginID TEXT (50), Password TEXT (50), FirstName TEXT (50), LastName TEXT (50), Department TEXT (50),"
sSql = sSql & "CONSTRAINT MyFieldConstraint PRIMARY KEY(LoginID, Password));"
....................................................................
'called in another function
If FindUser(sUserID, sPassword) = True Then
'change where am i
sWhereAmI = "DISPLAYUSER"
Else
iResult = MsgBox("There are no users with the ID and Password you entered, Would you like to add them", vbYesNo + vbQuestion, "Log In")
End If
...........................................................................
'called by the above code
Function FindUser(sUserName As String, sUserPW As String) As Boolean
Data1.Recordset.Index = "MyFieldConstraint"
Data1.Recordset.Seek "=", sUserName, sUserPW
'So that No match = True
FindUser = Not Data1.Recordset.NoMatch
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|