Hi,
I am trying to add a record with the INSERT INTO with parameters. Here is my
code. I get the error message now that it expects a ")". I have
tried a few different things, but to no avail. What am I doing wrong???? I
can't believe that it is so difficult to add a record in a database.
TIA
Roy
using System;
using System.Data;
using System.Data.OleDb;
using System.Xml.Serialization;
public class MainClass
{
public static void Main ()
{
test.xxx();
}
}
public class test
{
public static void xxx()
{
int lnvar1=10, lnvar2=20, lnvar3=30;
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\\dbAccess\\db1.mdb";
OleDbConnection myConnection = new OleDbConnection( connectionString );
myConnection.Open();
OleDbCommand myCommand = new OleDbCommand("insert into emp_test (emp_code,
emp_name, emp_ext) VALUES (?, ?,?)", myConnection);
myCommand.Parameters.Add(New SqlCeParameter("emp_code", SqlDbType.NText,
50));
myCommand.Parameters.Add(New SqlCeParameter("emp_name", SqlDbType.NText,
50));
myCommand.Parameters.Add(New SqlCeParameter("emp_ext", SqlDbType.NText,
50));
myCommand.Parameters("emp_code").Value = lnvar1;
myCommand.Parameters("emp_name").Value = lnvar2;
myCommand.Parameters("emp_ext").Value = lnvar3;
myCommand.ExecuteNonQuery();
myConnection.Close();
}