Using the Data Grid View control with SQL Commands

  • Thread starter Thread starter JohnDBCTX
  • Start date Start date
J

JohnDBCTX

Guest
Hello,

I have this code snippet in SQL Query Builder:

INSERT INTO IDNumbers ( IDNumber, IDName )
SELECT MAX(IDNumber)+1 AS NewID, NULL AS NewIDName
FROM IDNumbers

This SQL lines of code refer to the method, InsertQueryIDNumbers()

And here is the second code snippet:

Public Class Form1
Private Sub IDNumbersBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles IDNumbersBindingNavigatorSaveItem.Click
Me.Validate()
Me.IDNumbersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.NamesDBBackupOneDataSet)

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'NamesDBBackupOneDataSet.IDNumbers' table. You can move, or remove it, as needed.
Me.IDNumbersTableAdapter.Fill(Me.NamesDBBackupOneDataSet.IDNumbers)

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.IDNumbersTableAdapter.InsertQueryIDNumbers()

End Sub
End Class

Anyone can improve this code as they please. The main goal is to add a record to the data control grid.

So far, in the properties windows, I do not know which of the choices to select:

For the command type: The choices in the drop-down menu are: Text, Stored Procedure, and Table Direct.

And for the execute mode: The choices in the drop-down menu are: scalar, reader, and non query

Anyone who is willing to help me out would be great.


Regards,

JohnDBCTX



jp

Continue reading...
 
Back
Top