hi guys,
I have developed a website in asp.net vb which displays 1 record from my SQL server database table into a label, but i am looking to display all data within the table that fits the criteria onto the label.
Private Sub GetData()
Dim dt As New DataTable()
Dim connection As New SqlConnection("hidden data source*****")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT [Project_name] , [Project_consultant] , [Project_recordstatus] from Project WHERE Project_Recordstatus = 1", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlDa.Fill(dt)
If dt.Rows.Count > 0 Then
lblProject.Text = dt.Rows(0)("Project_name").ToString()
lblProject_consult.Text = dt.Rows(0)("Project_consultant").ToString()
lblProject_recordstatus.Text = dt.Rows(0)("Project_recordstatus").ToString()
End If
connection.Close()
End Sub
That is what I have so far,
what will I need to do to make it display all the records from the table?
is this the best way of displaying information? I read online about people using <#%eval %>?
Private Sub GetData()
Dim dt As New DataTable()
Dim connection As New SqlConnection("hidden data source*****")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT [Project_name] , [Project_consultant] , [Project_recordstatus] from Project WHERE Project_Recordstatus = 1", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlDa.Fill(dt)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
Sorry I should have explained, this is for the front end, so thats why I am not using gridviews, so I am then able to use Css to style the front end. example a user of the website would be seeing this page so it has to look good and not within a table is
ideally what I am looking for.
None
0 Points
2 Posts
binding data from a SQL Server to a label.
Sep 29, 2015 05:27 AM|phillips|LINK
hi guys,
I have developed a website in asp.net vb which displays 1 record from my SQL server database table into a label, but i am looking to display all data within the table that fits the criteria onto the label.
Private Sub GetData()
Dim dt As New DataTable()
Dim connection As New SqlConnection("hidden data source*****")
connection.Open()
Dim sqlCmd As New SqlCommand("SELECT [Project_name] , [Project_consultant] , [Project_recordstatus] from Project WHERE Project_Recordstatus = 1", connection)
Dim sqlDa As New SqlDataAdapter(sqlCmd)
sqlDa.Fill(dt)
If dt.Rows.Count > 0 Then
lblProject.Text = dt.Rows(0)("Project_name").ToString()
lblProject_consult.Text = dt.Rows(0)("Project_consultant").ToString()
lblProject_recordstatus.Text = dt.Rows(0)("Project_recordstatus").ToString()
End If
connection.Close()
End Sub
That is what I have so far,
what will I need to do to make it display all the records from the table?
is this the best way of displaying information? I read online about people using <#%eval %>?
Star
9021 Points
2401 Posts
Re: binding data from a SQL Server to a label.
Sep 29, 2015 05:32 AM|Lokesh B R|LINK
Hi,
If you want to display all the records you can use GridView/ListView/Repeater
Example
None
0 Points
2 Posts
Re: binding data from a SQL Server to a label.
Sep 29, 2015 05:40 AM|phillips|LINK
Sorry I should have explained, this is for the front end, so thats why I am not using gridviews, so I am then able to use Css to style the front end. example a user of the website would be seeing this page so it has to look good and not within a table is ideally what I am looking for.
Star
9021 Points
2401 Posts
Re: binding data from a SQL Server to a label.
Sep 30, 2015 02:42 AM|Lokesh B R|LINK
Hi,
Checkout this sample to display data from database to HTML table.
http://www.aspsnippets.com/Articles/Display-data-from-database-in-HTML-table-in-ASPNet.aspx