Click here to Skip to main content
15,891,375 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Ok i think ive got the code right but im getting this error when i run the program, Data type mismatch in criteria expression.

C#
{
           da.InsertCommand = new OleDbCommand("INSERT INTO Rented (DVDID, UserName) VALUES (@rent, @username)", conn);
           var currentUser = System.Web.Security.Membership.GetUser(User.Identity.Name);
           string username = currentUser.UserName; //** get UserName
          // string userName = Environment.UserName;


           da.InsertCommand.Parameters.AddWithValue("@rent", DG_Latest.SelectedRow.Cells[1].Text);
           da.InsertCommand.Parameters.AddWithValue("@username", currentUser.UserName);

           conn.Open();

           da.InsertCommand.ExecuteNonQuery();

           conn.Close();
           conn.Dispose();
       }
Posted

1 solution

Data Type Mismatch means that the data you're giving the DB does not match the data in the column of the database.
 
Share this answer
 
Comments
Ben Oats 23-Dec-13 17:23pm    
yep, column was set to currency not text...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900