I am a newbie in vb.net so I don't know how to do with this, I was trying to display the sum of the counted rows of a table from my database and it will be displayed in a textbox but after the execution it didn't show in the textbox, I don't know where I've got it wrong even though it doesn't have an error.
so far this is my code:
connect.Open()
da = New MySqlDataAdapter("Select * from tbl_book_info", connect)
Dim row As String
row = "Select count(ISBN) from tbl_book_info"
cmd = New MySqlCommand(row, connect)
READER = cmd.ExecuteReader
Dim count As Integer = 0
For Each rowcount As DataTable In dataset.Tables
count += rowcount.Rows.Count()
TextBox7.Text = count.ToString
Next
connect.Close()
thank you in advance :)
.Readon your reader for example, otherwise you will not read anything. No need to loop either as you should only return a scalar value that is your count... Make sure toDisposeof your objects as well, don't leave them in the yard... Where isdataset.Tablescoming from; you are notFillingone in which you would do from aDataAdapter? As you can see there are many issues, that is just a few of them. I would honestly start over and work your way down.cmd.ExecuteScalar();for the Count query., it will return the number of rows. No loop on something else needed.SQLnotMySQL. In this case just replace theSQLparts with theMySQLequivalent.