thanks Scott for your reply,
you are right, i am new to the .NET world and its a bit confusing!
this is the entire class:
Imports ADODB
Imports System.Data.OleDb
Imports System.Data.SqlClient
Module OpenDBConnection
Public MyfrmLogin As New frmLogin
Dim MyfrmMain As New frmMain
Dim cnn As New ADODB.Connection
Dim rsControl As New ADODB.Recordset
Dim strSQL As String 'this is the source
Dim strPath As String = Application.StartupPath()
Public Sub Main()
Try
'set the ado connection string
Dim strConnection As String = "Provider=" & "Microsoft.Jet.OLEDB.4.0;" &
"Data Source=C:\MyFolder\Data1.mdb;" & "Jet OLEDB:Database Password=" & ""
'try to open the ado connection
cnn.Open(strConnection)
'set cursor location of recordset to client...
'rsControl.CursorLocation = ADODB.CursorLocationEnum.adUseClient
MyfrmLogin.Show()
Application.Run() 'added this line and was able to keep the apllication
running
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
End Try
End Sub
Public Sub LogonProcess()
Dim UserLogin, UserPass As String
UserLogin = MyfrmLogin.txtUserName.Text.Trim()
UserPass = MyfrmLogin.txtPassword.Text.Trim()
Try
rsControl.CursorLocation = ADODB.CursorLocationEnum.adUseClient
strSQL = "SELECT * FROM Employees WHERE Username = '" & UserLogin & "' AND
Password = '" & UserPass & "'"
rsControl.Open(strSQL, cnn, CursorTypeEnum.adOpenStatic,
LockTypeEnum.adLockReadOnly, CommandTypeEnum.adCmdText) 'compiler gives
me an error in this line
With rsControl
If Not .EOF And Not .BOF Then
MyfrmMain.Show()
MyfrmLogin.Hide()
Else
MsgBox("Your login details are INCORRECT.")
End If
End With
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
End Try
End Sub
End Module
I added Application.Run() and was able to keep the application running. but
now when i try to open the recordset the program terminates and i get an
exception error. do you see anything wrong in this line:
rsControl.Open(strSQL, cnn, CursorTypeEnum.adOpenStatic,
LockTypeEnum.adLockReadOnly, CommandTypeEnum.adCmdText) 'compiler gives
me an error in this line
thanks a lot
"Scott M." <s-***@badspamsnet.net> wrote in message
news:uN*************@TK2MSFTNGP10.phx.gbl...
It sounds like (or reads like) you are new to .NET. I believe that your
Sub Main is being called but your form isn't.
All the code that you wrote below looks like typical VB 6 code, but VB.NET
isn't just VB 7.0, it's a complete re-write of the architecture and
therefore the language as well.
You're using classic ADO, trying to set a client-side cursor when you
could be using ADO.NET that natively works with disconnected data.
You're calling the show method of your form, but where is it's
instantiation?
"hkadhim" <ha******@canada.com> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl... hi all,
i am using the following:
Public Sub Main()
Try
'set the ado connection string
Dim strConnection As String = "Provider=" & "Microsoft.Jet.OLEDB.4.0;" &
"Data Source=C:\MyFolder\data1.mdb;" & "Jet OLEDB:Database Password=" &
""
'try to open the ado connection
cnn.Open(strConnection)
'set cursor location of recordset to client...
'rsControl.CursorLocation = ADODB.CursorLocationEnum.adUseClient
MyfrmLogin.Show()
Catch ex As Exception
MessageBox.Show(ex.ToString())
Finally
End Try
End Sub
I am trying to set the database connection from the Sub Main(). now when
i go to project properties, i selected Sub Main as the startup object but
it will show for a while and unload itself quickly. i used to do it in VB6
all the time but i am now with VB.NET 2003 i am a bit confused. how can i
force the project to start from the Sub Main()?
thanks alot