Problen : Insert Into Access database
-
A am using access mdb database and using obleDB class. when i run insert query on this table it runs successfully but record does not appear into data table. i am using .. objConnection1.Open(); objCommand = new OleDbCommand(Sqlstr, objConnection1); Data = objCommand.ExecuteNonQuery(); // it gives data = 1 my connection is ok because i am getting value using this connection when i use Executescalar() on this command object why it is.....
-
A am using access mdb database and using obleDB class. when i run insert query on this table it runs successfully but record does not appear into data table. i am using .. objConnection1.Open(); objCommand = new OleDbCommand(Sqlstr, objConnection1); Data = objCommand.ExecuteNonQuery(); // it gives data = 1 my connection is ok because i am getting value using this connection when i use Executescalar() on this command object why it is.....
-
A am using access mdb database and using obleDB class. when i run insert query on this table it runs successfully but record does not appear into data table. i am using .. objConnection1.Open(); objCommand = new OleDbCommand(Sqlstr, objConnection1); Data = objCommand.ExecuteNonQuery(); // it gives data = 1 my connection is ok because i am getting value using this connection when i use Executescalar() on this command object why it is.....
-
Whats your query string? i.e. the value of Sqlstr
Life goes very fast. Tomorrow, today is already yesterday.
string Sqlstr = "INSERT INTO student(stu_id,stu_fnm) VALUES (" + textBox1.Text.Trim() + ",'" + textBox2.Text.Trim() + "') "; // it is inserting record when i run it into sql pane . and objConnection1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=score.mdb");// is connection string // i tried same for sql server database it works fine // but i want to do it for access..
-
but i want to insert record into table .
-
string Sqlstr = "INSERT INTO student(stu_id,stu_fnm) VALUES (" + textBox1.Text.Trim() + ",'" + textBox2.Text.Trim() + "') "; // it is inserting record when i run it into sql pane . and objConnection1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=score.mdb");// is connection string // i tried same for sql server database it works fine // but i want to do it for access..
-
but i want to insert record into table .
Aw, I thought you wanted to insert your rows into a
DataTable
object. I should learn to read decently before answering a post. In that case theExecuteNonQuery
is correct, my apologies. That would return "1" if it added a record. You might want to use parameters in your Insert-statement, that would also prevent some problems with SQL Injection and quoted strings. Take a look atOleDbParameter
:)I are troll :)