SuPerNoVi
03-15-2007, 10:39 AM
Okay so here is my code thus far on the click of the update button...
Public Sub Update_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Update.Click
Dim command_builder As SqlCommandBuilder
Dim Connection As SqlConnection = New SqlConnection(C.ConnString)
Connection.Open()
Dim Command As SqlCommand = New SqlCommand()
Command.Connection = Connection
Command.CommandText = "Web_A2Z_GetValuesFromBasket"
Command.CommandType = CommandType.StoredProcedure
Dim Parameter As SqlParameter = New SqlParameter("@SearchString", "eid:t.jarram@gmail.com")
Parameter.Direction = ParameterDirection.Input
Parameter.DbType = DbType.String
Command.Parameters.Add(Parameter)
Dim insertCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Insert", "CustomerId", "CustomerName")
Dim updateCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Update", "CustomerId", "CustomerName", "TimeStamp")
Dim deleteCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Delete", "CustomerId")
'Dim Adapter As SqlDataAdapter = New SqlDataAdapter(Command)
Dim Adapter As New SqlDataAdapter(Command)
command_builder = New SqlCommandBuilder(Adapter)
Adapter.Update(DataSet)
End Sub
The bit in particular I am struggling with is the commands...
Dim insertCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Insert", "CustomerId", "CustomerName")
Dim updateCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Update", "CustomerId", "CustomerName", "TimeStamp")
Dim deleteCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Delete", "CustomerId")
I am trying to update the dataset and then pass it to the database at the end but what am I doing wrong. Do I have to create a stored procedure for each instance IE update or delete record?
Any help greatly appreciated :)
Public Sub Update_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Update.Click
Dim command_builder As SqlCommandBuilder
Dim Connection As SqlConnection = New SqlConnection(C.ConnString)
Connection.Open()
Dim Command As SqlCommand = New SqlCommand()
Command.Connection = Connection
Command.CommandText = "Web_A2Z_GetValuesFromBasket"
Command.CommandType = CommandType.StoredProcedure
Dim Parameter As SqlParameter = New SqlParameter("@SearchString", "eid:t.jarram@gmail.com")
Parameter.Direction = ParameterDirection.Input
Parameter.DbType = DbType.String
Command.Parameters.Add(Parameter)
Dim insertCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Insert", "CustomerId", "CustomerName")
Dim updateCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Update", "CustomerId", "CustomerName", "TimeStamp")
Dim deleteCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Delete", "CustomerId")
'Dim Adapter As SqlDataAdapter = New SqlDataAdapter(Command)
Dim Adapter As New SqlDataAdapter(Command)
command_builder = New SqlCommandBuilder(Adapter)
Adapter.Update(DataSet)
End Sub
The bit in particular I am struggling with is the commands...
Dim insertCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Insert", "CustomerId", "CustomerName")
Dim updateCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Update", "CustomerId", "CustomerName", "TimeStamp")
Dim deleteCommand As SqlCommand = SqlHelper.CreateCommand(Connection, "Customer_Delete", "CustomerId")
I am trying to update the dataset and then pass it to the database at the end but what am I doing wrong. Do I have to create a stored procedure for each instance IE update or delete record?
Any help greatly appreciated :)