Here is my cs file:
protected void Page_Load(object sender, EventArgs e)
{
Label1.Visible = false;
OleDbCommand com = new OleDbCommand(connectionstr);
com.Parameters.AddWithValue("@Action", HiddenField2.Value).ToString();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(com);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void btnsub_Click(object sender, EventArgs e) {
OleDbConnection con =Connection.DBconnection();
OleDbCommand com =new OleDbCommand("Insert into registration(username,class,section,address)values(@username,@class,@section,@address)",con);
com.Parameters.AddWithValue("@Action", HiddenField1.Value).ToString();
com.Parameters.AddWithValue("@username",Textusername.Text.Trim());
com.Parameters.AddWithValue("@pwd", Textclass.Text.Trim());
com.Parameters.AddWithValue("@email",Textsection.Text.Trim());
com.Parameters.AddWithValue("@address", Textaddress.Text.Trim());
com.ExecuteNonQuery();
Label1.Visible = true;
Label1.Text = "Records are Submmited Successfully";
}
I'm new to .net. I created student form using msaccess. And I insert the date into database. Now after submit the input details, I need to display in gridview after submission.
For that i used above code(from online), now it shows,
Selectcommand.connection property not initialized
In the line da.Fill(ds);
. I don't know sql server, so i m started using msacces.
May i know, how can i fix this issue?
Thanks,