Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All I m Using Window forms using c# server side code .

using access database . i add app config file in this app config i cretae this connection
XML
<add name="ROMS.Properties.Settings.DBRomsConnectionString" connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\Resources\DBRoms.mdb;Persist Security Info=True" providerName="System.Data.OleDb" />

Than i call this directly form.cs file
C#
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\USER\Desktop\ROMS\ROMS\ROMS\Resources\DBRoms.mdb");


i donot know how to call this connection string .


i get problem to insert point : -
C#
query = "INSERT INTO Employee(EmployeeID,LoginID,Department,Designation,FinYear1,FinYear2,Password,) VALUES('" + txtEmployeeId.Text + "','" + txtLoginId.Text + "','" + CBEmployeeDepartment.SelectedItem.ToString() + "','" + CBEmployeeDesignation.SelectedItem.ToString() + "','" + CBFinYear1.SelectedItem.ToString() + "','" + CBFinYear2.SelectedItem.ToString() + "','" + txtEmployeePassword.Text + "')";
con.Open();
cmd = new OleDbCommand(query, con);
cmd.ExecuteNonQuery();
con.Close();


I get error in Execute nonquery .

all data field value is text .
Posted
Updated 27-Jan-14 20:48pm
v4
Comments
karthik Udhayakumar 28-Jan-14 2:30am    
Hello Rohit,

Are you using window forms or webforms?pls be clear in writing the questions to help you
!
Rohit85 28-Jan-14 2:31am    
Window Forms .
karthik Udhayakumar 28-Jan-14 2:34am    
Pls Correct your question first ,change the heading as MsAccess connection issue or something like that and remove the place where you have mentioned as webform to winform ..And add the code were you are facing the issue..Then let us check how to resolve!
Rohit85 28-Jan-14 2:39am    
how will i edit question ? i did not get option
phil.o 28-Jan-14 2:46am    
Click on the 'Improve question' button at its bottom.

1 solution

Remove the last comma from INSERT query
query = "INSERT INTO Employee(EmployeeID,LoginID,Department,Designation,FinYear1,FinYear2,Password,) VALUES('" + 

EDIT

Don't use keywords/reserved words like Password. You have to add square brackets for that column like below but I wont recommend that. You should rename the column name( like Emp_Password )

[Password]
 
Share this answer
 
v4
Comments
Rohit85 28-Jan-14 4:10am    
dear it show Errot Syntax error in INSERT INTO statement.
thatraja 28-Jan-14 4:15am    
Ofcourse, the problem is in your query(unwanted comma at end). Did you read my answer fully?
Rohit85 28-Jan-14 4:26am    
I remove this comms than after it show this error
thatraja 28-Jan-14 4:36am    
Check updated answer
Rohit85 28-Jan-14 4:38am    
OK I Use this

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