Jump to content

Oledb Connection With Access


shyam
 Share

Recommended Posts

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

  • 2 months later...

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

  • 9 months later...

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...