Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: vb6 to vb.Net question


Message #1 by <yahden@y...> on Tue, 5 Dec 2000 10:11:01 -0600
I have a simple VB.NET question
I upgraded this simple testform to VB.NET
there are no compile errors but when i click on the comman button the
program hangs with a com error
it hangs when it reaches this line  rs.Open()
anybody has any ideas
TIA
Denis@r...

************************************************VB6*************************
********************


Private Sub Command3_Click()

Dim cn As New ADODB.Connection, rs As New ADODB.Recordset


Const DBPATH = "D:\Parma\Parma.mdb;Persist Security Info=False"

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPATH
Set rs.ActiveConnection = cn
rs.Source = "Select * from workers where ID = 1"
rs.Open
txtLastName.Text = rs("LastName")
txtFirstName.Text = rs("FirstName")
rs.Close
cn.Close
Set cn = Nothing
Set rs = Nothing



End Sub

************************************************VB.NET**********************
***********************

 Private Sub Command3_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs)

            Dim cn As ADODB.Connection = New ADODB.Connection()
            Dim rs As ADODB.Recordset = New ADODB.Recordset()


            Const DBPATH As String = "D:\Parma\Parma.mdb;Persist Security
Info=False"

            cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
DBPATH)
            rs.ActiveConnection = cn
            rs.Source = "Select * from workers where ID = 1"
            rs.Open()
            txtLastName.Text = rs.Fields("LastName").Value
            txtFirstName.Text = rs.Fields("FirstName").Value
            rs.Close()
            cn.Close()
            cn = Nothing
            rs = Nothing



        End Sub




  Return to Index