I heard about "Stored procedures" ...But I'm not sure when I should use it...It is only when I will display information from the database or could it be used even when saving to the database
I have the following code (which save a value from a textbox in database)...How do I convert this code so it use stored procedures instead...(if its possible to use stored procedures when saving )
Can someone please help me with that
This is the code-behind file, called addCity.aspx.vb:
Protected
Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim ConnString As String = ConfigurationManager.ConnectionStrings("Connectionstring").ConnectionString Dim strSQL As String = ("INSERT INTO MyTable( City ) VALUES ( @City") ) Dim Conn As New SqlConnection(ConnString) Dim Command As New SqlCommand("", Conn)Command.CommandText = strSQL
Dim City As New SqlParameter("@City", DbType.String)City.Value = tboxCity.Text
Command.Parameters.Add(City)
TryConn.Open()
Command.ExecuteNonQuery()
Conn.Close()
Response.Redirect("page2.aspx", False)
Catch Ex As ExceptionResponse.Redirect(
"error.aspx", False) End Try End Sub