-
Apr 23rd, 2012, 02:51 PM
#1
Thread Starter
New Member
problem in vb 6.0
Here's My Set of codes, but i've got a problem in my record "rs.open SQL, SETCONNECT, adOpenKeyset, adLockOptimistic"
But still the same problem. I ve got this error.
Run-time error '3709'
the connection cannot be used to perform this operation.
it is either closed or invalid in this context.
Please help me reconstruct my codes.
code
------------------------------------------------------------------------
Private Sub cmdcanacel_Click()
End
End Sub
Private Sub cmdok_Click()
Dim strsql As String
Dim rs As ADODB.Recordset
'OpenConnection
If txtusername.Text = "" Then
MsgBox "enter the user name", vbInformation
txtusername.SetFocus
Exit Sub
End If
If txtpassword.Text = "" Then
MsgBox "enter the user password", vbInformation
'txtpassword .SetFocus
Exit Sub
End If
Set rs = New ADODB.Recordset
strsql = "select loginname,loginpassword from login where loginname='" & txtusername.Text & "'and loginpassword='" & txtpassword.Text & "'"
rs.Open strsql, g_con, adOpenDynamic, adLockOptimistic (getting error in dis line)
If rs.EOF = False Then
welcome.Show
'MDI.Show
Else
MsgBox "Please! enter the username and password correctly", vbCritical
End If
rs.Close
End Sub
Private Sub Form_Load()
txtusername.Text = ""
frmconnection.Hide
End Sub
Private Sub txtpassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdok_Click
End If
End Sub
Private Sub txtusername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdok_Click
End If
End Sub
-
Apr 24th, 2012, 04:31 AM
#2
Hyperactive Member
Re: problem in vb 6.0
You haven't opened your connection g_con, this needs to be opened before you can open the record set.
You have a 'Open connection comment but no code to do it.
See this page for an example:
http://support.microsoft.com/kb/310985/EN-US
Rico
Using: VB.net & MS SQL
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
|