If i close the recordset then it automatically gets focussed to the login..can any1 help me out in rectifyin the code given below- - Dim rs As New ADODB.Recordset
-
Dim cn As New ADODB.Connection
-
Private Sub Command1_Click()
-
If Text1 = "" Then
-
MsgBox "enter the username", vbInformation + vbOKOnly, "login"
-
Text1.SetFocus
-
Exit Sub
-
End If
-
If Text2 = "" Then
-
MsgBox "enter the password", vbInformation + vbOKOnly, "login"
-
Text2.SetFocus
-
Exit Sub
-
End If
-
If Text1 <> "" And Text2 <> "" Then
-
If rs.State = 1 Then
-
rs.Close
-
Else
-
rs.Open "select * from login where username='" & Text1 & "' and password='" & Text2 & "'", cn, adOpenDynamic, adLockOptimistic, adCmdText
-
If rs.EOF = True Then
-
MsgBox "invalid username and pass", vbCritical + vbOKOnly, "login"
-
Text1 = ""
-
Text2 = ""
-
Text1.SetFocus
-
Else
-
MsgBox "username and pass corect", vbInformation + vbOKOnly, "login"
-
If vbOK Then
-
Unload Me
-
MDIForm1.Show
-
End If
-
End If
-
End If
-
End If
-
End Sub
-
-
Private Sub Command2_Click()
-
Unload Me
-
End Sub
-
-
Private Sub Form_Load()
-
Text1 = ""
-
Text2 = ""
-
cn.Open "Provider=MSDAORA.1;Password=tiger;User ID=system;Persist Security Info=True"
-
End Sub
4 1322
Hi
I suggest this mod - Private Sub Command1_Click()
-
If Text1 = "" Then
-
MsgBox "enter the username", vbInformation + vbOKOnly, "login"
-
Text1.SetFocus
-
Exit Sub
-
End If
-
If Text2 = "" Then
-
MsgBox "enter the password", vbInformation + vbOKOnly, "login"
-
Text2.SetFocus
-
Exit Sub
-
End If
-
If Text1 <> "" And Text2 <> "" Then
-
If rs.State = 1 Then
-
rs.Close
-
Else
-
rs.Open "select * from login where username='" & Text1 & "' and password='" & Text2 & "'", cn, adOpenDynamic, adLockOptimistic, adCmdText
-
If rs.EOF = True Then
-
MsgBox "invalid username and pass", vbCritical + vbOKOnly, "login"
-
Text1 = ""
-
Text2 = ""
-
Text1.SetFocus
-
Else
-
MsgBox "username and pass corect", vbInformation + vbOKOnly, "login"
-
If vbOK Then
-
Unload Me
-
MDIForm1.Show
-
End If
-
End If
-
rs.Close '########## CLOSE RECORDSET HERE !!
-
End If
-
End Sub
ie add rs.close where indicated on line 29.
Also 'If vbOK Then' is redundant as vbOK is always true !! (ie = 1)
HTH
MTB
well its still the same.I am getting the error pointed at cn.open in the form load...thank u in advance :)
I must confess I am puzzled why a connection should be open in the on load event but you could try this - If cn.State = adStateClosed Then cn.Open "Provider=MSDAORA.1;Password=tiger;User ID=system;Persist Security Info=True"
However I would change the module level declaration to - Dim rs As ADODB.Recordset
-
Dim cn As ADODB.Connection
And the load even to this - Private Sub Form_Load()
-
Text1 = ""
-
Text2 = ""
-
-
Set cn = New ADODB.Connection
-
Set rs = New ADODB.Recordset
-
-
cn.Open "Provider=MSDAORA.1;Password=tiger;User ID=system;Persist Security Info=True"
-
End Sub
and, although not strictly necessary in this instance, but just for completeness and good housekeeping(?), add this - Private Sub Form_Unload(Cancel As Integer)
-
If rs.State = adStateOpen Then rs.Close
-
Set rs = Nothing
-
-
cn.Close
-
Set cn = Nothing
-
End Sub
??
HTH
MTB
thank you anyways i figured the error :D it was actually my timer control enabled for progress bar which was causing all of the mess :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: N. Demos |
last post by:
I'm having problems with a custom JS object (XMLLoadObject) I designed
to load XML and XSL files, perform an XSL transform with them and embed
the resultant HTML fragment into the host HTML...
|
by: celtic_kiwi |
last post by:
I have an Access 97 database, quite large, and have started getting the
error, Error 3048: Can't Open any more databases.
-The data is split from the application (front end and back end).
-The...
|
by: J Gao |
last post by:
Hi, All,
I got this error when trying to compile a web project.
The file 'bin\Kennel.dll' cannot be copied to the run directory. The
requested operation cannot be performed on a file with a...
|
by: dejanvesic |
last post by:
Hello.
Windows service is in question, Framework 2.0, operating system is
Windows XP Prof.
Windows service is accessing file taking turns with ASP.NET
application.
For synhronisation of...
|
by: dp |
last post by:
hello,
I have service that copy dll file that contain information of one of
the sources of
the event viewer. the service is in system permission.
if someone used event viewer before the process ,...
|
by: deadlycow21 |
last post by:
I am trying to open a open file dialog:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
OpenFileDialog1.Filter = "*.mp3,...
|
by: TG |
last post by:
Hi!
Once again I have hit a brick wall here. I have a combobox in which
the user types the server name and then clicks on button 'CONNECT' to
populate the next combobox which contains all the...
|
by: sean_walsh |
last post by:
Hi
From classic ASP, I had a custom error handling situation that was
quite simple. Errors were all redirected to Error.asp. This page would
check 2 settings, EmailErrorMessage and...
|
by: Frisco Depot |
last post by:
I have a Run-time error problem on a Vista computer.
There are two computers involved,
The first one is Vista Home Premium SP1 with
Windows Mail Version 6.0.6000.16386 (vista_rtm.061101-2205)...
|
by: tirupathiraov |
last post by:
I have set the prepared statement ResultSet.HOLD_CURSORS_OVER_COMMIT and the same thing working on one instace of DB2 and not working on other instance of DB2. what could be the problem?
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |