Hello All
I am new to vb.net i am stuck in a problem
I am using vb,net as front end and sql server as backend. I want to display all records in a datagrid. Inserting data to the datasource is successful but it is not refreshing in datagrid .
Please help me . how to bind that updated row to the datagrid.
This is my lines of code .
VB Code:
Dim conn As New OleDbConnection("Provider=SQLOLEDB;user ID=sa;Password=dreams;DATABASE=mydb;server=localhost") Dim sda As New OleDbDataAdapter() Dim str As String Dim ds As New DataSet() str = "Select * from LessorDetails" sda = New OleDbDataAdapter(str, conn) sda.Fill(ds, "LessorDetails") Dim dt As New DataTable() dt = ds.Tables("LessorDetails") ds = Nothing Dim strqry As String Dim adapter As New OleDbDataAdapter() Dim dataset As New DataSet() strqry = "Insert into LessorDetails(LessorName) VALUES('" & txtLName.Text & "')" adapter = New OleDbDataAdapter(strqry, conn) adapter.Fill(dataset, "LessorDetails") Dim cb As OleDbCommandBuilder = New OleDbCommandBuilder(adapter) adapter.Update(dt) dataGrid1.Datasource=dt
Thanks in advance
Regards




Reply With Quote