System.__ComObject the same number of times as the of records in the table.
And NOTHING shows up in the DataGrid1
As usual I am at a complete loss as to understanding the difference between vb6 and vb.net. I never needed the .ToString() for the rs.fields in vb6
Any help is greatly appreciated.
Larry
Imports System.Data
Imports System.Data.OleDb
Imports ADODB
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Create a connection string
Dim DataGrid1 As New DataGrid
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\ecotest2\Nwind.mdb"
Dim sql As String = "SELECT CustomerId, CompanyName, ContactName From Customers"
' Create a Connection object and open it
Dim conn As Connection = New Connection
Dim connMode As Integer = ConnectModeEnum.adModeUnknown
conn.CursorLocation = CursorLocationEnum.adUseServer
conn.Open(ConnectionString, "", "", connMode)
'Dim recAffected As Object
Dim cmdType As Integer = CommandTypeEnum.adCmdText
Dim rs As _Recordset = conn.Execute(sql)
' Create dataset and data adpater objects
With rs
Do While Not rs.EOF
Debug.Print(rs.Fields("ContactName").ToString())
rs.MoveNext()
Loop
End With
Dim ds As DataSet = New DataSet("Recordset")
Dim da As OleDbDataAdapter = New OleDbDataAdapter
' Call data adapter's Fill method to fill data from ADO
' Recordset to the dataset
da.Fill(ds, rs, "Customers")
' Now use dataset
DataGrid1.DataSource = ds.DefaultViewManager
End Sub
End Class

New Topic/Question
Reply




MultiQuote




|