Populate label from SQL query...
-
Hi All Very new to SQL and ASP.Net but need to populate a lable from a SQL query.
Dim sqlDbAdapter1 As New Data.SqlClient.SqlDataAdapter("SELECT COUNT(*) AS myCount FROM dbo.IssueTb ", sqlconn) sqlDbAdapter.Fill(sqlDataset, "IssueTb") Dim Issuedv As DataView = sqlDataset.Tables("IssueTb").DefaultView
The above loads a Dataset and DataView with the value but I don't know to bind to the label on the web page. Databinding used on vb.net was my first try but this was wrong so could someone please help. Thanks Heaps...When people make you see red, be thankful your not colour blind.
-
Hi All Very new to SQL and ASP.Net but need to populate a lable from a SQL query.
Dim sqlDbAdapter1 As New Data.SqlClient.SqlDataAdapter("SELECT COUNT(*) AS myCount FROM dbo.IssueTb ", sqlconn) sqlDbAdapter.Fill(sqlDataset, "IssueTb") Dim Issuedv As DataView = sqlDataset.Tables("IssueTb").DefaultView
The above loads a Dataset and DataView with the value but I don't know to bind to the label on the web page. Databinding used on vb.net was my first try but this was wrong so could someone please help. Thanks Heaps...When people make you see red, be thankful your not colour blind.
Because you are only returning one column in one row you would be better off without the Data Adapter Dim cmd AS New SqlCommand() cmd.CommandText = "SELECT COUNT(*) FROM dbo.IssueTb" cmd.Connection = sqlConn Dim result As Int32 result = cmd.ExecuteScalar() ... SomeLabel.Text = result.ToString()
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog
-
Because you are only returning one column in one row you would be better off without the Data Adapter Dim cmd AS New SqlCommand() cmd.CommandText = "SELECT COUNT(*) FROM dbo.IssueTb" cmd.Connection = sqlConn Dim result As Int32 result = cmd.ExecuteScalar() ... SomeLabel.Text = result.ToString()
Upcoming Scottish Developers events: * UK Security Evangelists On Tour (2nd November, Edinburgh) * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog