Hi! im currently studying about the adodb connection and somehow i cant display the db on datagridview using adodb connection. I have a sample code of my recent project. Please help and reply asap thanks!
Private Sub GetDatatoGrid()
Try
Dim adconn As New ADODB.Connection()
adconn.ConnectionString = "DRIVER=MySQL ODBC 5.1 Driver;Server=10.237.250.252;uid=root;pwd=c0k3floa t;database=test;port=3306""Server=10.237.250.252;u id=root;pwd=c0k3float;database=test;port=3306"
adconn.Open()
Dim rs As New ADODB.Recordset()
rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rs.CursorType = ADODB.CursorTypeEnum.adOpenStatic
rs.LockType = ADODB.LockTypeEnum.adLockBatchOptimistic
rs.Open("select * from earvin", adconn.ConnectionString)
rs.ActiveConnection = Nothing
adconn.Close()
Dim da As New System.Data.OleDb.OleDbDataAdapter()
Dim ds As New DataSet()
da.Fill(ds, rs, "Table")
3: For x As Integer = 0 To ds.Tables(0).Rows.Count - 1
dataGV.Rows.Insert(0) 'this will add a new record on top, always
dataGV.Rows(0).Cells(0).Value = ds.Tables(0).Rows(x)("id")
dataGV.Rows(0).Cells(1).Value = ds.Tables(0).Rows(x)("name")
dataGV.Rows(0).Cells(2).Value = ds.Tables(0).Rows(x)("age")
dataGV.Rows(0).Cells(3).Value = ds.Tables(0).Rows(x)("position")
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
p.s. may i know the meaning of da.fill and its parameter esp the string parameter on it