Last post Dec 27, 2009 11:43 PM by anooj
Dec 27, 2009 09:10 PM|stevecist|LINK
I need to store 4 numbers into a database or file, for retrieval and exporting to the file.
I have tried the Insert statement to put the Textbox contents into a Access database but I
cannot get it to work. Is there a real easy way to store these four TextBoxes in a file or
database. I have read ASP.NET 1.1 with VB.NET 2003 but I still can't figure out how to do
this simple thing. I created a connection to my Access database but when I try to connect
to it and use the Insert command the numbers don't appear in the database.
I appreciate your help. Thank you.
Dec 27, 2009 11:20 PM|anzer|LINK
It is very easy to do INSERT operation in asp.net.. please see the data access tutorials available in this site to know how to do it..
Dec 27, 2009 11:21 PM|masoomnazir|LINK
Assume the access database where you are trying to insert the 4 values is Database.mdb.Following code should do it for you:
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection())
string database = Server.MapPath("Database.mdb");
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + database;
string commandtext = "INSERT INTO TABLENAME (field1,field2,field3,field4) VALUES (" + int.Parse(TextBox2.Text) + "," + int.Parse(TextBox3.Text) + "," + int.Parse(TextBox4.Text) + "," + int.Parse(TextBox5.Text) + ")";
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand(commandtext, conn);
cmd.CommandType = System.Data.CommandType.Text;
Dec 27, 2009 11:43 PM|anooj|LINK
I hope this helps...