Jump to content
Sign in to follow this  
shyam

Oledb Connection With Access

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();

Share this post


Link to post
Share on other sites

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();

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...