Insert into a db through ADO.NET

  • Thread starter Thread starter Claudia Fong
  • Start date Start date
C

Claudia Fong

Hi,

I'm trying to insert new datas to an existing table. What I learn from a
C# book, all I need to do is write a method


private void adepartment ()
{
// specify new department code to insert in database
objadep.Parameters["DEPT_CODE"].Value = textBox1.Text;

oleDbConnection1.Open();

objadep.ExecuteNonQuery(); --> generate this error: An unhandled
exception of type 'System.Data.OleDb.OleDbException' occured in
system.data.dll

oleDbConnection1.Close();
}

Can someone explain what this error means and how should I do?

Cheers!

Claudi
 
Ah! scott.dept, if I'm not mistaken..

I assume objadep is a member variable of type OleDBCommand?

Where do you define the command object and its parameters? Post that
code and someone will be able to help you.

hth

matt
 
I used the Query Builder which allows me to specify the commands that
retrieve information from and modify information in databases. But I
already found out what happen.. In the properties, the parameters
disapear




Cheers!

Claudi
 
Back
Top