Need help in retrieving and posting data to the database (ms access) from C#.net
I have just now completed C#.net and I have created form as well as the database connection using ms acess but then I don’t have much knowledge in retrieving and posting data to the database, is there anyone who has an idea about the same and can help me out with it??? Any help regarding this will be highly appreciated.
Re: Need help in retrieving and posting data to the database (ms access) from C#.net
Quote:
I have just now completed C#.net and I have created form as well as the database connection using ms acess but then I don’t have much knowledge in retrieving and posting data to the database, is there anyone who has an idea about the same and can help me out with it??? Any help regarding this will be highly appreciated.
You have not mentioned the scenario in your case, I mean the table name and the code that you might be trying out, if you need help from the start then you can just check out the below guide and see if it is helping:
How to retrieve and display records from an Access database by using ASP.NET,ADO.NET, and Visual C# .NET
Re: Need help in retrieving and posting data to the database (ms access) from C#.net
If you want then you can try out the below code, here the name of the table is customer information, when you will enter the customer name in one text then you will get the other information of the customer in other text boxes, if you have much idea about the card then you won’t have issues in understanding the below code:
Quote:
con.Open();
str = "Select * from customerinfo where(cname='" + textBox1.Text + "')";
cmd = new SqlCommand(str, con);
dr = cmd.ExecuteReader();
if(dr.HasRows)
{
while (dr.Read())
{
textBox2.Text = dr["customerid"].ToString();
textBox3.Text = dr["address"].ToString();
textBox4.Text = dr["contactno"].ToString();
textBox5.Text = dr["email"].ToString();
}
con.close();
dr.close();
}