Hello everybody,
I am trying to bind the reults of my query to a label on my form. I am doing this many times over into many different labels on the same form. I am building something like a summary report. This is what I am doing.
I am writing this statement again and again to count the different products I have. I am wondering, do I have to continuously fill my dataset with a new table full of information and then bind the results of that table to each label (appox 50 labels)? Is there a better way? Can I just read the results of my query and then pass that text to the label?
Thanks for the help
I am trying to bind the reults of my query to a label on my form. I am doing this many times over into many different labels on the same form. I am building something like a summary report. This is what I am doing.
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myconn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SqlConnection = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlConnection(cnxn)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] mysda [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlDataAdapter
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myds [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataSet = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myDV [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataView
[/SIZE]
[SIZE=2]mysda.SelectCommand = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand
mysda.SelectCommand.Connection = myconn
mysda.SelectCommand.CommandText = "SELECT count(*) as [count] FROM Products WHERE name like 'Chair%'"
mysda.SelectCommand.CommandType = CommandType.Text
myconn.Open()
mysda.Fill(myds, "1")
myconn.Close()
myDV = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataView(myds.Tables("1"))
[/SIZE][SIZE=2]lbl1.DataBindings.Add("text", myDV, "count")[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]
mysda.SelectCommand = [SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand
mysda.SelectCommand.Connection = myconn
mysda.SelectCommand.CommandText = "SELECT count(*) as [count] FROM Products WHERE name like 'Couch%'"
mysda.SelectCommand.CommandType = CommandType.Text
myconn.Open()
mysda.Fill(myds, "2")
myconn.Close()
myDV = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataView(myds.Tables("2"))
[/SIZE][SIZE=2]lbl1.DataBindings.Add("text", myDV, "count")[/SIZE]
[/SIZE]
I am writing this statement again and again to count the different products I have. I am wondering, do I have to continuously fill my dataset with a new table full of information and then bind the results of that table to each label (appox 50 labels)? Is there a better way? Can I just read the results of my query and then pass that text to the label?
Thanks for the help