I am new to asp.net I am really enjoying it however I have found something very inefficent when using sql server.
I have a dataset now I can poulate this in many ways but for this argument I will use 2
a sql string and calling a stored procedure
1.
sSQL = "SELECT * FROM tblCustomers WHERE Etc"
dapCustomersedit = New SqlDataAdapter("sSQL", cnn)
dsCustomersedit = New DataSet()
dapCustomersedit.Fill(sCustomersedit,"sp_customerdetails")
now I can do anything call the .update what ever. with few lines of code
Now when I read about sql inject ..I worry so I use stored procedures instead.
dapCustomersedit = New SqlDataAdapter("sp_customerdetails", cnn)
dapCustomersedit.SelectCommand.CommandType = CommandType.StoredProcedure
dapCustomersedit.SelectCommand.Parameters.Add(New SqlParameter("@CustID", SqlDbType.Int, 40))
dapCustomersedit.SelectCommand.Parameters("@CustID").Value = Session("sCustID")
dsCustomersedit = New DataSet()
dapCustomersedit.Fill(dsCustomersedit, "sp_customerdetails")
now I wanna update..so now I have to call another stored procedure this time an update sql and I have to pass and set every field with parameters on the stored procedure that heaps more code. I know you should have a layer of abstraction from the database but there must be a better way to update the stored procedure and what about code maintence if you add an extra field that you wish to pass a parameter to you have to do it in two places the stored procedure and the procedure in the code behind...is there another way or am I missing somthing?
My cat's name is sprinkles
-Ralph Wigam
I have a dataset now I can poulate this in many ways but for this argument I will use 2
a sql string and calling a stored procedure
1.
sSQL = "SELECT * FROM tblCustomers WHERE Etc"
dapCustomersedit = New SqlDataAdapter("sSQL", cnn)
dsCustomersedit = New DataSet()
dapCustomersedit.Fill(sCustomersedit,"sp_customerdetails")
now I can do anything call the .update what ever. with few lines of code
Now when I read about sql inject ..I worry so I use stored procedures instead.
dapCustomersedit = New SqlDataAdapter("sp_customerdetails", cnn)
dapCustomersedit.SelectCommand.CommandType = CommandType.StoredProcedure
dapCustomersedit.SelectCommand.Parameters.Add(New SqlParameter("@CustID", SqlDbType.Int, 40))
dapCustomersedit.SelectCommand.Parameters("@CustID").Value = Session("sCustID")
dsCustomersedit = New DataSet()
dapCustomersedit.Fill(dsCustomersedit, "sp_customerdetails")
now I wanna update..so now I have to call another stored procedure this time an update sql and I have to pass and set every field with parameters on the stored procedure that heaps more code. I know you should have a layer of abstraction from the database but there must be a better way to update the stored procedure and what about code maintence if you add an extra field that you wish to pass a parameter to you have to do it in two places the stored procedure and the procedure in the code behind...is there another way or am I missing somthing?
My cat's name is sprinkles
-Ralph Wigam