P
Pappa_1945
Guest
Respected Friends,
I have a MySQL table containing 2138 rows. But my code shows only 1639 rows and update is not taking effect after the row number of 1639. And also DatagridView is displaying 2138 rows. Please help me. My code is given bellow. Thanks.
My code to show the number of Rows:
mysqlconn = New MySqlConnection
mysqlconn.ConnectionString = "server=localhost;user id=root;password=1234;database=Share"
mysqlconn.Open()
Dim adapter As New MySqlDataAdapter("SELECT * FROM name_list;", mysqlconn)
Dim datatable As New DataTable()
Dim dataset As New DataSet
adapter.Fill(datatable)
adapter.Fill(dataset)
TextBox1.Text = datatable.Rows.Count
DataGridView1.DataSource = datatable
And my code to Update is
Dim mysqlconn As New MySql.Data.MySqlClient.MySqlConnection
mysqlconn.ConnectionString = "server=localhost;user id=root;password=1234;database=Share"
mysqlconn.Open()
Dim adapter As New MySqlDataAdapter("SELECT * FROM name_list;", mysqlconn)
Dim datatable As New DataTable()
adapter.Fill(datatable)
Dim cmd As New MySqlCommand
cmd.Connection = mysqlconn
Dim sql As String
Dim ii As Integer = 0
For Each rw As DataRow In datatable.Rows
sql = "UPDATE Name_list Set P_Numerology = NULL , Remark = NULL WHERE ID =" & (ii)
cmd.CommandText = sql
cmd.ExecuteNonQuery()
ii = ii + 1
Next
adapter.Fill(datatable)
DataGridView1.DataSource = datatable
Continue reading...
I have a MySQL table containing 2138 rows. But my code shows only 1639 rows and update is not taking effect after the row number of 1639. And also DatagridView is displaying 2138 rows. Please help me. My code is given bellow. Thanks.
My code to show the number of Rows:
mysqlconn = New MySqlConnection
mysqlconn.ConnectionString = "server=localhost;user id=root;password=1234;database=Share"
mysqlconn.Open()
Dim adapter As New MySqlDataAdapter("SELECT * FROM name_list;", mysqlconn)
Dim datatable As New DataTable()
Dim dataset As New DataSet
adapter.Fill(datatable)
adapter.Fill(dataset)
TextBox1.Text = datatable.Rows.Count
DataGridView1.DataSource = datatable
And my code to Update is
Dim mysqlconn As New MySql.Data.MySqlClient.MySqlConnection
mysqlconn.ConnectionString = "server=localhost;user id=root;password=1234;database=Share"
mysqlconn.Open()
Dim adapter As New MySqlDataAdapter("SELECT * FROM name_list;", mysqlconn)
Dim datatable As New DataTable()
adapter.Fill(datatable)
Dim cmd As New MySqlCommand
cmd.Connection = mysqlconn
Dim sql As String
Dim ii As Integer = 0
For Each rw As DataRow In datatable.Rows
sql = "UPDATE Name_list Set P_Numerology = NULL , Remark = NULL WHERE ID =" & (ii)
cmd.CommandText = sql
cmd.ExecuteNonQuery()
ii = ii + 1
Next
adapter.Fill(datatable)
DataGridView1.DataSource = datatable
Continue reading...