hello....
as i had changed da code .....silly error is coming while inserting data into database....
here is my code ....
protected void btnregister_Click(object sender, EventArgs e)
{
if (Page.IsValid == true)
{
con.Open();
string userstr="INSERT INTO User(Code,UserPass,FirstName,LastName,BDate,BMonth,BYear) VALUES('" + txtuserid.Text + "','" + txtPassword.Text + "','" + txtFirstName.Text + "','" + txtLastName.Text + "','" + ddlDay.SelectedItem.ToString() + "','" + ddlMonth.SelectedItem.ToString() + "','" + ddlYear.SelectedItem.ToString() + "');";
cmd = new OleDbCommand(userstr, con);
cmd.ExecuteNonQuery();
Response.Redirect("abc.aspx");
con.Close();
}
}
//here ddlDate,ddlMonth,ddlYear are 3 dropdownlist
it giving me error ..!!!
plz tell me where m going wrong?!
thanks in advance..
Loading
Kirtan PatelPosted Nov 4, 2009, 6:33 PM
Your [Problem solved ]
problem was in Database you have Used TableName 'User' which is Reserved KeyWord of Oledb so you cant use it as TableName.
so simply i Have changed it to 'UserData' from 'User' and It Worked :)
here is Corrected File
kritikaPosted Nov 4, 2009, 11:06 PM
Yeah Its working..
Though first da tablname was Users but i changed by User...
well didn't came in mind abt keyword at tht time...!!!
Thank u so much!! Kirtan..
kritikaPosted Nov 4, 2009, 2:19 PM
i had tried all solutions ...but error is there...
u can check the project file on mediafire uploaded as Sample.rar
plz give me the idea where i could be wrong..
thank u
Amit ChoudharyPosted Nov 4, 2009, 8:21 AM
just check your string in which you are constructing the query....... in the end you have added " ; " in the string. Remove it and it'll surely work fine.......
========================================
if it helps you mark it as answer..please it'll help me getting some points :)
Kirtan PatelPosted Nov 4, 2009, 7:15 AM
just Upload your project Files (Zip) to http://mediafire.com
and mail me the download link they give you at [email protected] :)
i will correct the mistake in your code and send you back :)
thanks :)
kritikaPosted Nov 4, 2009, 7:08 AM
infect i had changed by numeric type....
but error is same as coming....
it giving me insert into syntax error...!!!! m not getting ....is it da code is wrong?...or i missed something to write?
Kirtan PatelPosted Nov 4, 2009, 6:42 AM
if DataType of Date ,Month ,Year is Numeric then dont use ' ' quotes around it while passing the values in query it will solve your problem
and please check "Do you like this answer " check box if my answer helped you :)