Click here to Skip to main content
15,793,535 members
Please Sign up or sign in to vote.
1.17/5 (6 votes)
a form that accepts: Student Name , Email and Date of Birth (Calendar) when the
submit button clicked It should be stored on Sql sever database.please help me..
Updated 7-Oct-12 21:33pm
OriginalGriff 7-Oct-12 4:24am    
I'm sure English is not your native language, but it is the default language for this site.
In English, your question makes no sense at all.
Please, either try to find a better translation of your question to English, or find a site in your own native language, as they may be able to help you better than we can!
Use the "Improve question" widget to edit your question and provide better information.
ravichaitanya.m 7-Oct-12 5:58am    
If i am not wrong Do you want to know how actually data is stored in database whenever you click on Submit button in Application form?
If your answer is yes then here is the answer.

When you click submit button.In the background the code will do the following actions
1) Validate the Data--> if it is invalid data then it will prompt the user to validate
2)All the data is send to the DAL where you will use ADO.Net features to connect to Db and insert the data into corresponding tables.

please make sure your diction and vocabulary are apt. when posting here to get your desired answers
Sandip.Nascar 7-Oct-12 4:32am    
Your question makes no sense at all.
Sergey Alexandrovich Kryukov 8-Oct-12 2:55am    
Whatever you mean, you got my approval; now go ahead and implement it. :-)
As you did not ask any question, that's it.

1 solution

Use following code:

Table Creation :
/*SQL Query to create table*/
CREATE TABLE tblUserDetails
Name VARCHAR(30),
EmailID VARCHAR(40),
DateOfBirth VARCHAR(25)

C# Code :
SqlConnection con=new SqlConnection("ConfiguraionManager.ConnectionString["con"].ConnectionString");
SqlCommand cmd=new SqlCommand("insert into tblUserDetailsvalues('"+txtName.Text.Trim()+"','"+txtEmailID.Text.Trim()+"','"+txtDateOfBirth.Text.Trim()+"')",con);
int intResult=cmd.ExecuteNonExecuteQuery();
ScriptManager.RegisterStartUpScript(this,this.GetType(),"Message","alert('Saved Successfully')",true);
ScriptManager.RegisterStartUpScript(this,this.GetType(),"Message","alert('Unable to save try again')",true);

Share this answer
Zoltán Zörgő 8-Oct-12 3:01am    
Try not to suggest bad practice: you just made a security hole in the OP's application by concatenating the command, thus letting SQLi in. Using parameter is the good practice, especially when using direct user input.
Sergey Alexandrovich Kryukov 8-Mar-13 21:23pm    
Absolutely correct. Very bad answer. Nagaraj should be responsible for answers and understand that bad answer is much worse than no answer and can make harm to the OP and some readers.
I hope that such comment serve as a safeguard against bad answers. This is very good that we have such review system.

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