Stored Procedure using ASP.Net
I am creating an insert form which basically has three fields(name,password and department). I have created a stored procedure for insertion. I have also created a .cs file which handles all my connection settings including connection object ,command object. Now the problem is how to pass the values in th textbox to the class file.

Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Apr 10, 2009, 8:46 AM EDT
Check out the below link
http://www.macronimous.com/resources/calling_stored_procedures_from_ASP.NET_and_VB.NET.asp
Thanks -- Vijaya Kadiyala
www.DotNetVJ.com
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 10, 2009, 9:00 AM EDT
Say your store procedure will accept two input parameter.
and you want to pass textbox value to store procedure.Please check the following code
my store procedure name is SPR_GetBoothdetails
SqlCommand sqlComm;
string strConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
sqlConn = new SqlConnection(strConnectionString);
string strvalu1 =txtValu1.Text;
string strvalu2 =txtValu2.Text;
sqlComm = new SqlCommand("SPR_GetBoothdetails", sqlConn);
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters.Add(new SqlParameter("@str_valu1",strvalu1));
sqlComm.Parameters.Add(new SqlParameter("@str_valu2", strvalu2));
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Apr 14, 2009, 10:04 AM EDT
Hi
When you are implementing like this keep in mind about "SQL Injection" attack.
Thanks -- Vijaya Kadiyala
www.DotNetVJ.com
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 14, 2009, 9:06 PM EDT
For sql injection you can refer the following URL:
1.http://forums.asp.net/t/1362351.aspx
2.http://dotnet.dzone.com/news/aspnet-preventing-sql-injectio
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Apr 15, 2009, 7:06 AM EDT
Niradhip, you are very fast..not giving any chance to post answers :)
Thanks -- Vijaya Kadiyala
www.DotNetVJ.com
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 15, 2009, 8:42 PM EDT
Hahaha, I will slow down Vijaya.:-)
Vijaya KadiyalaRank #1,085 · 1.8K reputationPosted Apr 16, 2009, 9:56 AM EDT
20Miles/hour is ok ;)
randheer singh3 reputationPosted Apr 16, 2009, 6:29 PM EDT
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Apr 17, 2009, 4:11 AM EDT
That you should tell me Vijaya........
You are welcome Randheer Singh