A
Angelina
I have written this code for an onclick event of a button
so that i can run a stored procedure i created in access.
The SPROC performs an insert of 2 values into a table.
here is my code:
Private Sub Button1_Click(ByVal sender As
System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim Cn As New SqlConnection("initial
catalog=TestCaraDBmsde;integrated
security=SSPI;persist
security info=False;workstation id=USER;packet
size=4096")
Dim cmd As New SqlCommand("SPInsMeal", Cn)
cmd.CommandType =
CommandType.StoredProcedure
cmd.Parameters.Add( _
New SqlParameter("@Meal_desc",
SqlDbType.Char, 50)).Value = txtMealdesc.Text
cmd.Parameters.Add(New SqlParameter("@Cost",
SqlDbType.Money))
Try
Cn.Open()
cmd.ExecuteNonQuery()
Catch ex as Exception
ex.tostring()
Finally
Cn.Close()
End Try
When i check the database for the inserted values, they
are not there. Is there something that im not doing
correctly or missing out?
so that i can run a stored procedure i created in access.
The SPROC performs an insert of 2 values into a table.
here is my code:
Private Sub Button1_Click(ByVal sender As
System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim Cn As New SqlConnection("initial
catalog=TestCaraDBmsde;integrated
security=SSPI;persist
security info=False;workstation id=USER;packet
size=4096")
Dim cmd As New SqlCommand("SPInsMeal", Cn)
cmd.CommandType =
CommandType.StoredProcedure
cmd.Parameters.Add( _
New SqlParameter("@Meal_desc",
SqlDbType.Char, 50)).Value = txtMealdesc.Text
cmd.Parameters.Add(New SqlParameter("@Cost",
SqlDbType.Money))
Try
Cn.Open()
cmd.ExecuteNonQuery()
Catch ex as Exception
ex.tostring()
Finally
Cn.Close()
End Try
When i check the database for the inserted values, they
are not there. Is there something that im not doing
correctly or missing out?