Avatar of Brant Snow
Brant Snow
 asked on

c# parameterized stored procedures

I have alot of sql in some of my code that i want to switch out to parameterized stored procedures.

I see lots of tutorials out there, just wondering if you have any best practice approachs to recommend, or if there is anything within the entity framework or some microsoft class that would make sense and help.

For example, if you look at this URL  https://msdn.microsoft.com/en-us/library/vstudio/zxsa8hkf(v=vs.100).aspx
Its a tutorial for a stored procedure through managed code

Why would you do this vs just writing it directly to the database?

Anyway best advice or approaches would be appreciated.
C#.NET ProgrammingASP.NET

Avatar of undefined
Last Comment
Kamal Khaleefa

8/22/2022 - Mon
SOLUTION
Carl Tawn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Kamal Khaleefa

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Kamal Khaleefa

and here is the connection to db

Public Function StartConnection() As SqlConnection



        Dim con As SqlClient.SqlConnection = Nothing
       

        '   Dim ConnectionString As String = "Data Source=server;Initial Catalog=dbname;Persist Security Info=True;User ID=sa;Password=*****; "
       
       
     


        Try
            con = New SqlClient.SqlConnection(ConnectionString)
         
        Catch ex As Exception
     
 
        End Try
        Return con




    End Function

Open in new window

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes