Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 03, 2012 05:38 PM by Truptir
Member
10 Points
69 Posts
Apr 03, 2012 05:13 PM|LINK
SqlDataAdapter da = new SqlDataAdapter("insert into Student_Registration_Details values('" + dd_branchreg.Text + "','" + dd_cc.Text + "','" + dd_cname.Text + "','" + dd_batch.Text + "','" + txtbox_studid.Text + "','" + txtbox_regidate.Text + "','" + txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "','" + txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'" + txtbox_addr.Text + "','" + txtbox_addr2.Text + "','" + txtbox_addr3.Text + "','" + txtbox_city.Text + "','" + txtbox_state.Text + "','" + txtbox_country.Text + "'," + txtbox_pincode.Text + ")", conn); ds1.Clear(); da.Fill(ds1);
after inserting values into forms and click on add button i am getting incorrect syntax near and it is showing email address i am inputting into form . but this querry is correct i am not getting where i am going wrong
Participant
1754 Points
340 Posts
Apr 03, 2012 05:18 PM|LINK
Try:
+ txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "'," + txtbox_dob.Text + ",'" +
or
+ txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "','" + txtbox_dob.Text + "','" +
I hope this helps.
All-Star
95503 Points
14106 Posts
Apr 03, 2012 05:22 PM|LINK
I am not sure about the error why you are getting, but you need change the coding way...you need to use Parameterized queries rather than concatenating likw what you have did...http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx
to solve your error probably you might need to see your input email string...
Thanks,
Contributor
3026 Points
564 Posts
Apr 03, 2012 05:25 PM|LINK
hi, in the below line of your code , you forgot one single qoute.
+ txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'"
please checkall the qoutes are mtched or not.
hope tis will help you
2396 Points
661 Posts
Apr 03, 2012 05:32 PM|LINK
Your mistake is very clear
rdbuttonlist_gender.Text + "','" + txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'"
see the underlined area : there is atrting quote for txtbox_dob.Text but no closing quote that's the reason for email error
Apr 03, 2012 05:38 PM|LINK
2nd one is working ...i was missing single quotes near d_o_b
thanx!!
Truptir
Member
10 Points
69 Posts
Incorrect syntax near
Apr 03, 2012 05:13 PM|LINK
SqlDataAdapter da = new SqlDataAdapter("insert into Student_Registration_Details values('" + dd_branchreg.Text + "','" + dd_cc.Text + "','" + dd_cname.Text + "','"
+ dd_batch.Text + "','" + txtbox_studid.Text + "','" + txtbox_regidate.Text + "','"
+ txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "','"
+ txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'"
+ txtbox_addr.Text + "','" + txtbox_addr2.Text + "','" + txtbox_addr3.Text + "','"
+ txtbox_city.Text + "','" + txtbox_state.Text + "','" + txtbox_country.Text + "',"
+ txtbox_pincode.Text + ")", conn);
ds1.Clear();
da.Fill(ds1);
after inserting values into forms and click on add button i am getting incorrect syntax near and it is showing email address i am inputting into form . but this querry is correct i am not getting where i am going wrong
silvioyf
Participant
1754 Points
340 Posts
Re: Incorrect syntax near
Apr 03, 2012 05:18 PM|LINK
Try:
+ txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "'," + txtbox_dob.Text + ",'" +or
+ txtbox_fname.Text + "','" + txtbox_lname.Text + "','" + rdbuttonlist_gender.Text + "','" + txtbox_dob.Text + "','" +I hope this helps.
ramiramilu
All-Star
95503 Points
14106 Posts
Re: Incorrect syntax near
Apr 03, 2012 05:22 PM|LINK
I am not sure about the error why you are getting, but you need change the coding way...you need to use Parameterized queries rather than concatenating likw what you have did...http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx
to solve your error probably you might need to see your input email string...
Thanks,
JumpStart
sujithkumar
Contributor
3026 Points
564 Posts
Re: Incorrect syntax near
Apr 03, 2012 05:25 PM|LINK
hi, in the below line of your code , you forgot one single qoute.
+ txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'"
please checkall the qoutes are mtched or not.
hope tis will help you
tdmca
Contributor
2396 Points
661 Posts
Re: Incorrect syntax near
Apr 03, 2012 05:32 PM|LINK
Your mistake is very clear
rdbuttonlist_gender.Text + "','"
+ txtbox_dob.Text + ",'" + txtbox_email.Text + "'," + txtbox_telephone.Text + ",'"
see the underlined area : there is atrting quote for txtbox_dob.Text but no closing quote that's the reason for email error
Truptir
Member
10 Points
69 Posts
Re: Incorrect syntax near
Apr 03, 2012 05:38 PM|LINK
2nd one is working ...i was missing single quotes near d_o_b
thanx!!