Hi all
i made one window base application in VS2008 (VB.net).
i
made one simple code where i can insert data.and after inserting i can
see that data on grid.when i am inserting data insert query runs
perfect.after that for debugging purpose i fire select query and get
result in dataset and its show data too.but when go into database my
inserted data not showing there.
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
Table test
cust_id numeric(18, 0)
cust_name varchar(50)
My
Store Procedures
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
TY IN ADVANCE