Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con_str As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True" Dim con As SqlConnection = New SqlConnection(con_str) Dim cmd, cmd2 As SqlCommand Dim adp As New SqlDataAdapter Dim ds As New DataSet With adp .SelectCommand = New SqlCommand With .SelectCommand .CommandType = CommandType.StoredProcedure .CommandText = "test_insert" If con.State = ConnectionState.Closed Then con.Open() End If .Parameters.Add("cust_name", SqlDbType.VarChar).Value = "hello" .Connection = con End With .Fill(ds, "insert") End With With adp .SelectCommand = New SqlCommand With .SelectCommand .CommandType = CommandType.StoredProcedure .CommandText = "test_select" If con.State = ConnectionState.Closed Then con.Open() End If .Connection = con End With .Fill(ds, "select") End With End Sub End Class
cust_id numeric(18, 0) cust_name varchar(50)
ALTER PROCEDURE test_insert @cust_name varchar(50) AS insert into test(cust_name) values (@cust_name) RETURN
ALTER PROCEDURE test_select AS select * from test RETURN
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)