Link to home
Start Free TrialLog in
Avatar of Rowel Virgo
Rowel VirgoFlag for Philippines

asked on

Hi I have a question in VB.net From SQL

        Dim cmd As MySqlCommand = conn.CreateCommand()
        cmd.CommandText = "SELECT * FROM rsv.tbl_accounts where user_name = '" & TextBox6.Text & "'"
        cmd.CommandType = CommandType.Text
        conn.Close()
        conn.Open()
        Dim count = cmd.ExecuteScalar()
        cmd.Clone()
        Label21.Text = count

Open in new window


About the above code, I want to display the user_name in Label21.text but it display the first column of the table from database because the user_registration_date is in the first column and the user_name is on the 3rd column. How can I display it? The 'rowelv' in Label21.text ???

Thanks

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rowel Virgo

ASKER

Thanks, yes I just forgot about the function of * in SQL query. I need more practice and familiarizing code in SQL I'm still a newbie. Thank you sir Pawan Kumar for the fast reply.
first of all

1. why do you close and open connection?
2. whats the point of providing username and selecting username?
3. whats the point of cmd.Clone()? do you mean cmd.Close()?
Welcome.
first of all

1. why do you close and open connection?
2. whats the point of providing username and selecting username?
3. whats the point of cmd.Clone()? do you mean cmd.Close()?

It's a mistakes again sir