DataBind vs DataBindings?

snow1

Member
Joined
Apr 21, 2006
Messages
17
Programming Experience
Beginner
Hi. How can i bind data to datagrid?
there are no DataBind available. An Error notification keeps on showing up once i type "DataBind". (It says: 'DataBind' is not a member of System.Windows.Forms.DataGrid) There is one close though, DataBindings. But I don't know how to use it. anyone help me?


Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim ObjConnection As OleDb.OleDbConnection
Dim ObjReader As OleDb.OleDbDataReader
Try
Dim StrConn As String = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BELL;Data Source=XPUSER"
Dim strSQL As String
strSQL = "SELECT * FROM Product"
ObjConnection =
New OleDb.OleDbConnection(StrConn)
Dim ObjCommand As New OleDb.OleDbCommand(strSQL, ObjConnection)
ObjConnection.Open()
ObjReader = ObjCommand.ExecuteReader()
myDataGrid.DataSource = ObjReader
myDataGrid.DataBind()

Catch ex As Exception
MsgBox(ex.Message)
End Try


End Sub
 
about databind

I am also new to vb.net

are u writing window application?
it seems that databind is for asp web application, not for window application..

just remove myDataGrid.DataBind() will be fine I think...
 
Back
Top