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 PatelRank #292 · 8.6K reputationPosted Nov 4, 2009, 1:33 PM EST
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
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 4, 2009, 1:42 AM EST
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 :)
kritika49 reputationPosted Nov 4, 2009, 2:08 AM EST
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 PatelRank #292 · 8.6K reputationPosted Nov 4, 2009, 2:15 AM EST
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 :)
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 4, 2009, 3:21 AM EST
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 :)
kritika49 reputationPosted Nov 4, 2009, 9:19 AM EST
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
kritika49 reputationPosted Nov 4, 2009, 6:06 PM EST
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..