- Parameter name not spelt correctly
- Case is not correct in parameter (firstname instead of FirstName )
- Passing incorrect type, for example, numeric instead of string - pass the string within quote
Welcome to VBA Tips & Tricks. All VBA related information will be posted on this blog. Of late, VBA has been disregarded by many software professionals for .Net, c# and other technologies. This blog will also post articles related to them too Happy reading
how can pass variables in values
ReplyDeleteOleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:/Users/syedzohererj/Documents/Database1.accdb;Persist Security Info=False;");
ReplyDeletestring commandString = "select * from Customer where ID=@Account";
OleDbCommand cmd = con.CreateCommand();
cmd.Parameters.Add("@Account", OleDbType.Integer).Value = int.Parse(textBox1.Text);
OleDbDataAdapter da = new OleDbDataAdapter(commandString, con);
DataSet ds = new DataSet();
da.Fill(ds, "table1");
int curr = (int.Parse(textBox1.Text) - 1);
DataTable dt = ds.Tables["table1"];
textBox2.Text = dt.Rows[curr]["employee"].ToString();
textBox3.Text = dt.Rows[curr]["Address"].ToString();
textBox4.Text = dt.Rows[curr]["contact"].ToString();
ds.AcceptChanges();
Here's a new reason why it could generate that error statement: list of header names is too long! To check examine your range definition (ctrl-F3). If the last column header is truncated, you will know you have a problem
ReplyDeletesaved a life cause 1 of my parameters was spelled incorrectly and i never saw it and i was looking and getting frustrated. Thanks
ReplyDelete