Insert into a db through ADO.NET

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
 
M

matthew_glen_evans

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
 
C

Claudia Fong

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top