Having Trouble inserting into Access Database.

The following attachments are:

Capture --> Actual Code
Capture2 ---> Access Database
Capture3 --> Error Message

public string saveTrace(Trace aTrace)
        {
            //get values from Transaction instance
            string traceID = "";
            decimal amount = aTrace.getAmount();
            string transType = aTrace.getTransType();
            string dID = aTrace.getDealerID();
            string dsID = aTrace.getDealershipID();
            string VIN = aTrace.getVIN();
            DateTime date = aTrace.getDate();

             
            OleDbCommand cmd=new OleDbCommand();

            cmd.CommandText = "insert into Trace (DS_ID,D_ID, Trace_Type, T_Amount, T_Date, VIN) values (@DS_ID, @D_ID, @Trace_Type, @T_Amount, @T_Date, @VIN)";
      
           
            cmd.Connection=ConnectionClass.getConnection();

               

            

            cmd.Parameters.AddWithValue("@DS_ID",dsID);

            cmd.Parameters.AddWithValue("@D_ID",dID);

            cmd.Parameters.AddWithValue("@Trace_Type",transType);

            cmd.Parameters.AddWithValue("@T_Amount",amount);
          
            cmd.Parameters.AddWithValue("@T_Date",date);

            cmd.Parameters.AddWithValue("@VIN",VIN);

            cmd.ExecuteNonQuery();

            cmd.Connection.Close();

By the way...this is the best source for IT/Developer questions that I have seen on the internet.

Thanks,

Derek

IIRC, Access doesn't support @ parameters, you have to use ? and then make sure you add them in order:

cmd.CommandText = "insert into Trace (DS_ID,D_ID, Trace_Type, T_Amount, T_Date, VIN) values (?, ?, ?, ?, ?, ?)";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.