DustyCarpet
Member
- Joined
- Sep 4, 2013
- Messages
- 8
- Programming Experience
- 1-3
Hi
I have added a bound datatable from a dataset created with the wizard and dragging and dropping the datatable. Rather than use the binging navigator I have added my own edit/add/delete buttons.
When I click add I would like to set the ID text box to the max ID +1 from the sql table.
If had built the sql connection my self i would do something like:
However when its done with a wizard i don't even know the name of the variable name for the connection string to run a sql command. Any ideas how I can run a sql command or another method to do this.
thanks
I have added a bound datatable from a dataset created with the wizard and dragging and dropping the datatable. Rather than use the binging navigator I have added my own edit/add/delete buttons.
When I click add I would like to set the ID text box to the max ID +1 from the sql table.
If had built the sql connection my self i would do something like:
VB.NET:
Dim maxIdCommand As SqlCommand = New SqlCommand _
("SELECT MAX(BRCID) AS MaxID " & _
"FROM [VOLUNTEERS].[ContactDetails]", objConnection)
' Open the connection, execute the command
objConnection.Open()
Dim maxId As Object = maxIdCommand.ExecuteScalar()
txtBRCID.Text = maxId + 1
' Close the connection..
objConnection.Close()
However when its done with a wizard i don't even know the name of the variable name for the connection string to run a sql command. Any ideas how I can run a sql command or another method to do this.
thanks