Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a porblem ,
I connected my wpf project to a microsoft access to insert and retreive data to the database .
when i open my project to insert data , then i can preview the data in another windnow , there is no problem untli the next point .
when i open my project again i can't retrieve the previous data which were entered .

And this is part ot the insert code :
OleDbConnection oConn = new OleDbConnection(ConnSt);
try
{
    OleDbCommand oComm = new OleDbCommand(
         "insert into MyData(CLName,CLAge,CLMajor) values('"
         + clientName.Text
         + "','" 
         + clientAge.Text 
         + "','"
         + ClientMajor.Text
         + "'")
    , oConn);
    oConn.Open();
    oComm.ExecuteNonQuery();
    oConn.Close();
}
catch (Exception exepc)
{
    MessageBox.Show(" There is a problem," + exepc.ToString());
}


Can you help me ? :confused:

Thank you in advance.
Posted
Updated 9-Mar-10 14:12pm
v2

NEVER put unchecked text directly into SQL.


Use parameters, that will solve your problem, and the SQL Injection issues you have.

These 2 articles will help you a lot.

Don't hard code your DataProviders

Secure Password Authentication Explained Simply
 
Share this answer
 
v2
Thank you ,Alaric .
you are right , but the problem in this situation i just disocvered .
Simply it is because i put the access file inside my project . so every time i execute the query ,it refresh the access file .
 
Share this answer
 

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