Link to home
Start Free TrialLog in
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.
SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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