Minato Arisato Minato Arisato - 5 months ago 52
MySQL Question

Retrieving Single Database/Cell from table mysql to Vb.net

I'm making a program in which the label text will change according to the retrieved data. But the only thing/command I found are retrieving data by column or by record. I need to get only a single data/cell.

I already know how to connect and use sql commands in Vb.net by as I said earlier I can't retrieve a single data/cell.

I found a function called mysql_fetch_array but I think It's only for Php not for Vb or I am I mistaken?


This will do it for you !
- you need the limit command added to your query !
- for better performance i suggest using order by !

Dim conn as MySqlConnection
    Dim cmd As MySqlCommand

    conn = New MySqlConnection("server=localhost;user id=root;password=;database=db_name;")

    cmd = New MySqlCommand("SELECT col_name FROM table_name WHERE col_name='values' LIMIT 1", conn)