SteveInBeloit
Well-known member
- Joined
- May 22, 2006
- Messages
- 132
- Programming Experience
- 10+
I am having some trouble updating a dataGridView via the toolstrip.
Here is how I loaded the datagridview:
All works good.
I added a toolstrip, and added a Text Button to it that says "Save". Then I went to put the code behind the save:
I don't know what to put in the ????. The first set should be the adapter, but I don't think it will be able to see it (out of scope). So I tried to declare them more globably like this:
But I get the squiglly line under the New SqlDataAdapter saying Type SqlDataAdapter not defined.
And I am not for sure what to put under the second set of ???'s.
Any help?
Thanks
Here is how I loaded the datagridview:
VB.NET:
Dim myConnection As New SqlConnection(strConn)
Dim selCmd As SqlCommand = myConnection.CreateCommand
Dim dt As DataTable = New DataTable
Dim da As SqlDataAdapter = New SqlDataAdapter(selCmd)
selCmd.CommandText = "spForkLiftTaskStatusSum"
selCmd.CommandType = CommandType.StoredProcedure
da.Fill(dt)
Me.BindingSource2.DataSource = dt
'then in the designer, set the DGV to BindingSource2
All works good.
I added a toolstrip, and added a Text Button to it that says "Save". Then I went to put the code behind the save:
VB.NET:
Me.Validate()
Me.BindingSource2.EndEdit()
Me.????.Update(???)
I don't know what to put in the ????. The first set should be the adapter, but I don't think it will be able to see it (out of scope). So I tried to declare them more globably like this:
VB.NET:
Public myConnection1 As New SqlConnection(strConn)
Public selCmd1 As SqlCommand = myConnection1.createCommand
Public da1 As SqlDataAdapter = New SqlDataAdapter(selCmd1)
But I get the squiglly line under the New SqlDataAdapter saying Type SqlDataAdapter not defined.
And I am not for sure what to put under the second set of ???'s.
Any help?
Thanks
Last edited: