mimitan
Technical User
- Dec 17, 2004
- 34
Hi everyone,
I have a form page in ASPnet when the Submit button is clicked, a stored procedure in SQL is called and the pararmeters of data in this form (such as first and Last name and so on) will be passed and inserted into a SQL table of a UserInfo DB.
Here is a segment of code in the Button_click procedure:
Session("date") = DateText.Text
Session("fname") = FirstNameText.Text
Session("lname") = LastNameText.Text
Dim Conn As String = "Data Source=SERVER1;Initial Catalog=UserInfo;Persist Security Info=True;User ID=sa;Password=password"
Dim sysobj As New System.Data.SqlClient.SqlConnection(Conn)
Dim cmd As New System.Data.SqlClient.SqlCommand("InsertInto_tblUserInfo", sysobj)
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@date", System.Data.SqlDbType.DateTime))
cmd.Parameters("@date").Value = Session("date")
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@fname", System.Data.SqlDbType.VarChar))
cmd.Parameters("@fname").Value = Session("fname")
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@lname", System.Data.SqlDbType.VarChar))
cmd.Parameters("@lname").Value = Session("lname")
.
.
.
sysobj.Open()
cmd.ExecuteNonQuery()
sysobj.Close()
End Sub
This procedure works but my question is: Is there a better way or a faster way to insert or update data into a SQL2005 DB table?
Thanks for your help
I have a form page in ASPnet when the Submit button is clicked, a stored procedure in SQL is called and the pararmeters of data in this form (such as first and Last name and so on) will be passed and inserted into a SQL table of a UserInfo DB.
Here is a segment of code in the Button_click procedure:
Session("date") = DateText.Text
Session("fname") = FirstNameText.Text
Session("lname") = LastNameText.Text
Dim Conn As String = "Data Source=SERVER1;Initial Catalog=UserInfo;Persist Security Info=True;User ID=sa;Password=password"
Dim sysobj As New System.Data.SqlClient.SqlConnection(Conn)
Dim cmd As New System.Data.SqlClient.SqlCommand("InsertInto_tblUserInfo", sysobj)
cmd.CommandType = System.Data.CommandType.StoredProcedure
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@date", System.Data.SqlDbType.DateTime))
cmd.Parameters("@date").Value = Session("date")
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@fname", System.Data.SqlDbType.VarChar))
cmd.Parameters("@fname").Value = Session("fname")
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@lname", System.Data.SqlDbType.VarChar))
cmd.Parameters("@lname").Value = Session("lname")
.
.
.
sysobj.Open()
cmd.ExecuteNonQuery()
sysobj.Close()
End Sub
This procedure works but my question is: Is there a better way or a faster way to insert or update data into a SQL2005 DB table?
Thanks for your help