Click here to Skip to main content
15,892,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created a contact form having field name, email, and message . I have one button for saving it. I have created one sp also to insert the data which is working fine . I am facing problem in front end . Till now what i have done is created a sql connection and added a parameter same which i use in sp. Please help me in writing that code. I will be very Thankful for this help.

My code

SQL
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["contact form"].ToString());
           SqlCommand cmdselect = new SqlCommand();
           cmdselect.CommandType = CommandType.StoredProcedure;
           cmdselect.CommandText = "USP_ContactDetails";
           cmdselect.Parameters.Add("@NAME", SqlDbType.NVarChar, 400).Value = nameinput.Text.Trim();
           cmdselect.Parameters.Add("@EMAIL", SqlDbType.NVarChar, 1000).Value = emailinput.Text.Trim();
           cmdselect.Parameters.Add("@MESSAGE", SqlDbType.NVarChar, 400).Value = textinput.Trim();


Regards
Posted
Comments
Jameel VM 3-Sep-13 1:17am    
what's the pblm?where you are stuck?
Member 9954101 3-Sep-13 1:21am    
Hi,

Basically that button is not showing any response . Also , that button is not a asp:Button , Its just a html code .so, whether it will work on it or i have to use asp:button for it . Though i have given its function name in the code ie Sndbtn_Click() to Onclick.
Thomas ktg 3-Sep-13 1:25am    
Hi,
Make sure you open the connection and execute the command just like this
con.Open();
cmdselect.ExecuteNonQuery();
Thanks7872 3-Sep-13 1:19am    
I am facing problem in front end means what?
Member 9954101 3-Sep-13 1:26am    
c# Code . Which i have written . The button is not responding anything.

1 solution

You have defined a command and passed it some parameters, but you haven't actually executed it!!
 
Share this answer
 
Comments
Thanks7872 3-Sep-13 1:29am    
+5
Member 9954101 3-Sep-13 1:37am    
by using cmdselect.ExecuteNonQuery(); command if am not wrong ?
Thanks7872 3-Sep-13 1:42am    
ya of course.
Member 9954101 3-Sep-13 1:47am    
Thanks Rohan , I will check and get back to u. :)
Thanks7872 3-Sep-13 1:47am    
Sure.

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