HomeHome  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  

Share | 
 

 Add data to database

Go down 
AuthorMessage
John



Number of posts : 7
Registration date : 2007-03-03

PostSubject: Add data to database   Sat Mar 03, 2007 6:14 pm

Add data to database

Hi
I got an error for the following code.
The error is "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll"

The error is with the ExecuteNonQuery line.


if(textBox1.Text != "" && textBox3.Text != "")
{
dataSet1.Clear();
oleDbDataAdapter1.InsertCommand.CommandText = "INSERT INTO Final (Invoice Number, Name, Amount) VALUES ('"+textBox1.Text+"', '"+textBox2.Text+"', '"+Int32.Parse(textBox3.Text) +"')";
oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
oleDbDataAdapter1.Fill(dataSet1);
}

What I want to do is to add values into the database, and I can't get it to work..Can anyone please help
Back to top Go down
View user profile
Admin
Admin


Number of posts : 10
Registration date : 2007-03-02

PostSubject: Re: Add data to database   Sat Mar 03, 2007 6:17 pm

hi John

Try this code

if(textBox1.Text != "" && textBox3.Text != "")
{
dataSet1.Clear();
oleDbDataAdapter1.InsertCommand.CommandText = "INSERT INTO Final ([Invoice Number], [Name],[ Amount]) VALUES ("+textBox1.Text+", '"+textBox2.Text+"', "+textBox3.Text +")";
oleDbDataAdapter1.InsertCommand.ExecuteNonQuery();
oleDbDataAdapter1.Fill(dataSet1);
}
Back to top Go down
View user profile http://programmers.top-board.com
 
Add data to database
Back to top 
Page 1 of 1
 Similar topics
-
» selenium with database testing
» Gang Tag Database
» How to pass the multiple input data with or condition to search them?
» How can i store all the commandsused by rc in a database??
» Pass multiple test data record to run test suite recursively

Permissions in this forum:You cannot reply to topics in this forum
 :: Programming Languages :: C#-
Jump to: