I'm writing a program where I need to have the label that I'm working query a row in table that I have in a DB.
The problem is that I don't want to put it around a button or a click. I may not be saying that right.
Here's the code I have so far:
Dim cmd As New SqlCommand Dim conn As New SqlClient.SqlConnection Dim sqlcmd As New SqlClient.SqlCommand Dim ad As New SqlClient.SqlDataAdapter Dim ds As New DataSet conn.ConnectionString = ("Data Source=localhost;Initial Catalog=holman;User ID=sa;Password=1q2w3e4r5t") sqlcmd.CommandText = "SELECT TOP 1 * FROM logininfo ORDER BY ID DESC" conn.Open() sqlcmd.Connection = conn ad.SelectCommand = sqlcmd ad.Fill(ds, "0") sqlcmd.ExecuteNonQuery() Label4.Text = sqlcmd.ExecuteNonQuery
When I look at the form a check the label or when I click on the label until I get the update feature worked out where it automatically updates to when I do have to click over the label or use a button to update what's there.
I was reading some earlier postings and thought I had it right. The return value that I am getting from the form is a -1.
Any help you can provide with this would be greatly appreciated.