I have code to save records to my mysql database.
But first I want to read what is the last number of record and add 1000 on that? What is the proper way to query that first. Thanks.
I want to make the result at unique ID of my clients. Here is my chunks of codes.
And for my saving to database buttonCode:Private Sub addClient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim conn As MySqlConnection conn = New MySqlConnection With conn If .State = ConnectionState.Open Then .Close() .ConnectionString = cnString .Open() End With Dim strSQL As String = "SELECT * from tblclients" daClients.SelectCommand = New MySqlCommand(strSQL, conn) Dim myCB As MySqlCommandBuilder = New MySqlCommandBuilder(daClients) daClients.Fill(dsClients, "Clients") conn.Close() End Sub
Code:Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim dt As DataTable = dsClients.Tables("Clients") Dim newRow As DataRow newRow = dt.NewRow() newRow("lastName") = txtLastname.Text newRow("firstName") = txtFirstname.Text dt.Rows.Add(newRow) daClients.Update(dsClients, "Clients") MsgBox("Record successfully saved.", MsgBoxStyle.Information) End Sub




Reply With Quote