Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Access in c#

Author  Topic 

messi
Starting Member

47 Posts

Posted - 2009-10-27 : 11:18:53
No value given for one or more required parameters.
this message i get when i try to execute this code in c#:

public partial class FormAddCustomer : Form
{
string con = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\Tailoers.mdb;Persist Security Info=False";

public FormAddCustomer()
{
InitializeComponent();
}

private void buttonsave_Click(object sender, EventArgs e)
{
OleDbConnection cnn = new OleDbConnection(con);
OleDbCommand command = new OleDbCommand("Insert into Customers (CustomerName,CustomerTelephone) Values (" + textBoxname.Text + ",'" + textBoxtele.Text + "')", cnn);
cnn.Open();
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
cnn.Close();
}
}


any one help please

Sequin
Starting Member

25 Posts

Posted - 2009-10-29 : 11:25:36
This error message often means that you have misspelt the name of a table or column - check your insert statement closely.

It
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2009-10-29 : 12:23:14
its far much, better, neater in .net to use objects instead of creation your connection string on the fly
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2009-10-29 : 13:30:09
Read this very carefully:

http://weblogs.sqlteam.com/jeffs/archive/2006/07/21/10728.aspx

Always use parameters for this type of stuff, never concatenation. The error you are having has to deal with an issue trying to "build" a sql statement with your data embedded in it (hint: you are missing delimiters) which you should never, ever do -- always simply use parameters.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -