Click here to Skip to main content
15,898,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;Data Source=sravs.mdb");
                    
OleDbCommand command = new OleDbCommand(
                 "INSERT INTO login(userid,password) VALUES ( "+"@UserId,@Password )",con );
try
{
   con.Open();
   command .ExecuteNonQuery ();
                     
   MessageBox.Show("Connection Open ! ");
   con.Close();
Posted
Updated 6-Mar-13 3:55am
v3
Comments
[no name] 6-Mar-13 9:04am    
What is it that you think "VALUES ( "+"@UserId,@Password )" is going to do in your query?
ZurdoDev 6-Mar-13 9:14am    
You need to add the parameters with command.Parameters.AddWithValue.
Sandeep Mewara 6-Mar-13 9:56am    
You have not shared the full code base. Please share it. There are few code lines that are important is missing.
Mostafa Metwally 6-Mar-13 13:51pm    
you should declare the parameters

1 solution

Hi,use following code and go ahead ....
i tested this and its working fine .*(here Name and Password field is Text type)

C#
string conectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=../../sravs.mdb";
            OleDbConnection con = new OleDbConnection(conectionString);

            OleDbCommand command = new OleDbCommand("INSERT INTO Login([Name],[Password]) VALUES ('Ramejhs','kdjskjks')", con);

            con.Open();
            command.ExecuteNonQuery();

            con.Close();
jmd
::-)
 
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