I have been able to insert textbox text into ms access database table but i cannt display the gridview on web form and retrive data from the table .
I have just gotten into asp.net and have tried few ways to do this but dont understand well enough.
if someone could show me some code that i could add to my form i would appreciate it
Thanks
Imports System.Data.OleDb Public Class WebForm1 Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb2.accdb") Dim CmdStr As String = "insert into sample (emp_name,category,city) values ('" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')" con.Open() Dim cmd As OleDbCommand = New OleDbCommand(CmdStr, con) cmd.ExecuteNonQuery() con.Close() MsgBox("Done") End Sub Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\testdb2.accdb") Dim Query2 As String = "select * from Sample" Dim Da As OleDbDataAdapter, Ds As New DataSet, Dtb As New System.Data.DataTable con.Open() Da = New OleDbDataAdapter(Query2, con) Da.Fill(Ds) con.Close() Dtb = Ds.Tables(0) GridView1.DataSource = Dtb GridView1.DataBind() End Sub End Class.