When I used VB6 I would explicitly access SQL servers in that I did not use the data environment, rather I would use code like:
I am just wondering if this is the best way to do this in ADO.NET.Code:Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Set cn = New ADODB.Connection Set rs = New ADODB.Recordset With cn .Provider = "SQLOLEDB" .ConnectionString = "Data Source=SQLServer;Initial Catalog=MyCat" .Open End With rs.Open "SELECT * FROM Table1" Text1.Text = rs!Field
Thanks!!




Reply With Quote