TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Michael Mount
NA
8
2.1k
asp.net insert query
Jun 9 2014 1:18 AM
I am trying to insert into an access database and cannot get it to add any records. I've been working on this problem for days and cannot get it to work. Here's my code.
Oledbconnection constring = new Oledbconnection(Connection String Here");
string strInsertEmployee = "Insert into tblEmployees(EmployeeID, EmployeeFirstName, EmployeeLastName, EmployeePhoneNumber, EmployeeVanNumber, EmployeeMeterNumber, EmployeeTabletNumber, EmployeePassword, EmployeeActive)Values(@EmployeeID, @
EmployeeFirstName, @EmployeeLastName, @EmployeePhoneNumber, @EmployeeVanNumber, @EmployeeMeterNumber, @EmployeeTabletNumber, @EmployeePassword, @EmployeeActive);
OledbCommand cmdInsertEmployee = new oledbcommand(strInsertEmployee, constring);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeID", Convert.Tostring(strEmployeeID));
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeFirstName", strEmployeeFirstName);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeLastName", strEmployeeLastName);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeePhoneNumber", Convert.Tostring( strEmployeePhoneNumber));
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeVanNumber", strEmployeeVanNumber);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeMeterNumber", strEmployeeMeterNumber);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeTabletNumber", strEmployeeTabletNumber);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeePassword", strEmployeePassword);
cmdInsertEmployee.Parameters.AddWithValue("@EmployeeActive", strEmployeeActive);
cmdInsertEmployee.Connection = constring;
constring.open();
cmdInsertEmployee.executeNonQuery();
constring.Close();
I know my connectionstring is good because I have a select statement that returns records, but I just can't get this to insert.
Thanks
Reply
Answers (
6
)
.NET
Cannot insert records