On the surface, one would think this is simple. Apparently not.
Background: Accustomed to ASP VBScript. Updated to ASP.Net VB. All I want to do is draw data using a simple SQL Statement as you see below.
Dim dbconn As New SqlConnection
dbconn = New SqlConnection(ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString)
Dim cmd As SqlCommand
Dim cmdString As String = "Select * from tblUsers where fldUserID=1"
cmd = New SqlCommand(cmdString, dbconn)
dbconn.Open()
Label1.Text = **** normally in VBScript, I would put something like rs("fldUserValue") ****
dbconn.Close()
Now what? ASP.Net has lots of datalists, readers, views, pagers, etc. All I want to do, is pull a single flippin' field from the table listed above and do a simple math calculation and assign it to a variable. Do I use a DataReader?
Sir, you should use GridView control for displayng data. Do you know how populate data to GridView? You can not use only Label1.Text ==, it's nothing display.
executivefus...
Member
1 Points
10 Posts
Get Data from an SQL Database
Feb 20, 2013 04:39 PM|LINK
On the surface, one would think this is simple. Apparently not.
Background: Accustomed to ASP VBScript. Updated to ASP.Net VB. All I want to do is draw data using a simple SQL Statement as you see below.
Dim dbconn As New SqlConnection
dbconn = New SqlConnection(ConfigurationManager.ConnectionStrings("dbConnectionString").ConnectionString)
Dim cmd As SqlCommand
Dim cmdString As String = "Select * from tblUsers where fldUserID=1"
cmd = New SqlCommand(cmdString, dbconn)
dbconn.Open()
Label1.Text = **** normally in VBScript, I would put something like rs("fldUserValue") ****
dbconn.Close()
Now what? ASP.Net has lots of datalists, readers, views, pagers, etc. All I want to do, is pull a single flippin' field from the table listed above and do a simple math calculation and assign it to a variable. Do I use a DataReader?
Really frustrated.
adamturner34
Contributor
3890 Points
971 Posts
Re: Get Data from an SQL Database
Feb 20, 2013 05:03 PM|LINK
Yes you want to loop through a datareader
executivefus...
Member
1 Points
10 Posts
Re: Get Data from an SQL Database
Feb 20, 2013 08:51 PM|LINK
How do I pull the value from the field?
kszymaniak
Member
205 Points
112 Posts
Re: Get Data from an SQL Database
Feb 22, 2013 06:58 PM|LINK
Sir, you should use GridView control for displayng data. Do you know how populate data to GridView? You can not use only Label1.Text ==, it's nothing display.
Regards