shyam Posted July 29, 2009 Share Posted July 29, 2009 before reading this post i want to clearify that i have no problem in this ..It is just for beginnerHOW TO INSERT DATA IN ACCESS DATABASE USING C#.NET string con = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= C:/Documents and Settings/shyam/My Documents/Visual Studio 2008/Projects/databaseofaccess/db1.mdb; User Id=; Password="; OleDbConnection conn = new OleDbConnection(con); string cmd = "insert into logindetail (id,pwd) values(@id,@pwd)"; OleDbCommand cmdd = new OleDbCommand(cmd, conn); conn.Open(); //cmdd.Parameters.Add("id",OleDbType.Char,ValueType=TextBox1.Text.ToString()); //cmdd.Parameters.Add("pwd", OleDbType.Char), ValueType = TextBox2.Text.ToString()); cmdd.Parameters.Add("@id", OleDbType.Char).Value = TextBox1.Text.ToString(); cmdd.Parameters.Add("@pwd", OleDbType.Char).Value = TextBox2.Text.ToString(); cmdd.ExecuteNonQuery(); conn.Close(); Link to comment Share on other sites More sharing options...
s.geethika Posted October 20, 2009 Share Posted October 20, 2009 Great before reading this post i want to clearify that i have no problem in this ..It is just for beginnerHOW TO INSERT DATA IN ACCESS DATABASE USING C#.NET string con = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= C:/Documents and Settings/shyam/My Documents/Visual Studio 2008/Projects/databaseofaccess/db1.mdb; User Id=; Password="; OleDbConnection conn = new OleDbConnection(con); string cmd = "insert into logindetail (id,pwd) values(@id,@pwd)"; OleDbCommand cmdd = new OleDbCommand(cmd, conn); conn.Open(); //cmdd.Parameters.Add("id",OleDbType.Char,ValueType=TextBox1.Text.ToString()); //cmdd.Parameters.Add("pwd", OleDbType.Char), ValueType = TextBox2.Text.ToString()); cmdd.Parameters.Add("@id", OleDbType.Char).Value = TextBox1.Text.ToString(); cmdd.Parameters.Add("@pwd", OleDbType.Char).Value = TextBox2.Text.ToString(); cmdd.ExecuteNonQuery(); conn.Close(); Link to comment Share on other sites More sharing options...
sukhdev_ce Posted August 10, 2010 Share Posted August 10, 2010 Hi!You Have use This MethodOleDBConnection COn= New OleDBConnection("ConectionStringPassed Here");Con.Open();SqlSTMT="Insert Into TableName(Field1,Field2) Values(' "+TextBox1.Tex+"',"'+TextBox2.Tex+"')";OleDBCommand Cmd= new OleDBCommand(SqlSTMT,COn);Cmd.ExcuteNonQuery();Your Record will be inserted. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.