CSharp Use Stored Procedure To Insert Data – ADO.Net Database

<%@ Import namespace="system.data" %>
<%@ Import namespace="system.data.sqlclient" %><script language="vb" runat="server">
Private Sub Page_Load(ByVal Source As Object, ByVal E As EventArgs)  Dim sql As String = "InsertEmployee"
  Dim strConnection As String = "Data Source=whsql-v08.prod.mesa1.secureserver.net;Initial Catalog=DB_49907;User ID=w3mentoruser;Password='password';"
  Dim conn As New SqlConnection(strConnection)  conn.Open()  Dim cmd As New SqlCommand(sql, conn)
  cmd.CommandType = CommandType.StoredProcedure  cmd.Parameters.Add("@FirstName", "M")
  cmd.Parameters.Add("@LastName", "S")  Try
    cmd.ExecuteNonQuery()
  Catch ex As Exception
    Response.Write("Error: " & ex.Message & "<br/>")
  End Try
    cmd.Connection.Close()
  End Sub
</script>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.