K
Kees de Winter
Hi,
If I want to display some text value coming out of a database on an aspx
page (on a label), do I really have to create a connection and command
object etc. all manually (such as in the code below) or is there an easier
way (asp.net 2.0, VS 2005) ?
Thanks for your help!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("DevDbConnectionString"
).ToString)
If Not Page.IsPostBack Then
Dim strQuery As String = "SELECT CategoryID FROM Category WHERE
CategoryURL='" + Page.Request("dir") + "'"
Dim myCommand As New SqlCommand(strQuery, myConnection)
myConnection.Open()
Dim strCategoryID As String
strCategoryID = myCommand.ExecuteScalar
myConnection.Close()
End If
[..]
End Sub
If I want to display some text value coming out of a database on an aspx
page (on a label), do I really have to create a connection and command
object etc. all manually (such as in the code below) or is there an easier
way (asp.net 2.0, VS 2005) ?
Thanks for your help!
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationManager.ConnectionStrings("DevDbConnectionString"
).ToString)
If Not Page.IsPostBack Then
Dim strQuery As String = "SELECT CategoryID FROM Category WHERE
CategoryURL='" + Page.Request("dir") + "'"
Dim myCommand As New SqlCommand(strQuery, myConnection)
myConnection.Open()
Dim strCategoryID As String
strCategoryID = myCommand.ExecuteScalar
myConnection.Close()
End If
[..]
End Sub