Help in data selecting
-
hi i can select all the data from access database using c# ... now i want to do is get the data from the database and display it in my textbox .... i am using repeater control to get data from database ... but unable to display it in my textbox field .... here is my all code with repeter control for selecting data. :) file name is db2.aspx <%@ Page Language="C#" Debug="True" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> void Page_Load(object sender, EventArgs e) { } void Button1_Click(object sender, EventArgs e) { OleDbConnection objConnection = null; OleDbCommand objCmd = null; string strConnection, strSQL; strConnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\database\\sample.mdb"); objConnection = new OleDbConnection(strConnection); objConnection.Open(); strSQL = "INSERT INTO emp (fname, lname) VALUES ( '"+TextBox1.Text+"' , '"+TextBox2.Text+"' )"; objCmd = new OleDbCommand(strSQL, objConnection); objCmd.ExecuteNonQuery(); objConnection.Close(); TextBox1.Text=""; TextBox2.Text=""; string oledbcon,oledbcom; oledbcon = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\database\\sample.mdb"); OleDbDataAdapter mycommand1 = new OleDbDataAdapter("Select fname,lname from emp",oledbcon); DataSet ds = new DataSet(); mycommand1.Fill (ds,"emp"); rept.DataSource = ds.Tables["emp"].DefaultView; rept.DataBind(); objConnection.Close(); }
Access DataBase Is Inserting And View Data In Repeater.
First Name:
Last Name: