Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to save data from a DataTable in vb.net.
But nothing happened


VB
Dim dt As DataTable = DirectCast(Me.DataGridList.DataSource, DataTable)
        Using command As MySqlCommand = StrSettingConn.CreateCommand()
            command.CommandTimeout = 0
            command.CommandType = CommandType.Text
            command.CommandText = "INSERT INTO Demo (Name, Address) VALUES (@Name, @Address)"
            command.Parameters.Add("@Name", MySqlDbType.VarChar, 100, "Name")
            command.Parameters.Add("@Address", MySqlDbType.VarChar, 100, "Address")

            Using adapter As New MySqlDataAdapter()
                adapter.InsertCommand = command
                adapter.Update(dt)
            End Using
        End Using
Posted
Updated 22-Mar-15 11:18am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900