473,399 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Newby question

Hi

I need help at the very beginning. I have been writing classic ASP for some
time, but getting data out of a SQL database and displaying a single value
eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where code =
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")

to get a record out of the database. All I want to do now put the Name in
that record into a variable and use it in the HTML text. I would appreciate
any help.

Thank you
Hermann
Nov 18 '05 #1
12 1130
First off, the Fill method is a method of the SqlDataAdapter class so to use
Fill, you'd have to create a data adapter first, but you don't need a
dataset for what you're doing. Use the ExecuteScalar() method of the
SqlCommand class to return a single value. Search the framework
documentation for "Obtaining a Single Value from a Database".

In order to use that server side variable in your HTML, do it just as you
would in classic ASP:

<p>Product name for product code 0117 is: <%= myVariable %>.</p>
Dale

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP for some time, but getting data out of a SQL database and displaying a single value
eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where code = 0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")

to get a record out of the database. All I want to do now put the Name in
that record into a variable and use it in the HTML text. I would appreciate any help.

Thank you
Hermann

Nov 18 '05 #2
Hello Hermann,

An dataset is probably complete overkill for what you're trying to accomplish here.

Try this:

(c# code, but VB should be pretty similar)
SqlConnection myConnection = new SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial Catalog=database;");
SqlCommand cmd = new SqlCommand("select name from products where code = 0117", myConnection);

string s = (string)cmd.ExecuteScalar();

ExecuteScalar will receive one value from a database. It is up to you to cast it to the appropriate type.

HTH,

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3
Hello DalePres,

Dale, in his code example, he was creating a SqlDataAdapter. The variable name was just wrong. ;)
First off, the Fill method is a method of the SqlDataAdapter class so
to use Fill, you'd have to create a data adapter first, but you don't
need a dataset for what you're doing. Use the ExecuteScalar() method
of the SqlCommand class to return a single value. Search the
framework documentation for "Obtaining a Single Value from a
Database".

In order to use that server side variable in your HTML, do it just as
you would in classic ASP:

<p>Product name for product code 0117 is: <%= myVariable %>.</p>

Dale

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP
for

some
time, but getting data out of a SQL database and displaying a single
value eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where
code

=
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")
to get a record out of the database. All I want to do now put the
Name in that record into a variable and use it in the HTML text. I
would

appreciate
any help.

Thank you
Hermann

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #4
You're right. I didn't catch that one at all. I guess that's why variable
naming is so important.

Dale

"Matt Berther" <mb******@hotmail.com> wrote in message
news:OQ*************@TK2MSFTNGP09.phx.gbl...
Hello DalePres,

Dale, in his code example, he was creating a SqlDataAdapter. The variable name was just wrong. ;)
First off, the Fill method is a method of the SqlDataAdapter class so
to use Fill, you'd have to create a data adapter first, but you don't
need a dataset for what you're doing. Use the ExecuteScalar() method
of the SqlCommand class to return a single value. Search the
framework documentation for "Obtaining a Single Value from a
Database".

In order to use that server side variable in your HTML, do it just as
you would in classic ASP:

<p>Product name for product code 0117 is: <%= myVariable %>.</p>

Dale

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP
for

some
time, but getting data out of a SQL database and displaying a single
value eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where
code

=
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")
to get a record out of the database. All I want to do now put the
Name in that record into a variable and use it in the HTML text. I
would

appreciate
any help.

Thank you
Hermann

--

--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #5
You should look at the Microsoft Data Access Application Block. This
simplifies the process a great deal. In any case, whether you use the
application block or not, if you just want one value, you can use the
ExecuteScalar method of the SQLCommand class to readily return it, or the
equivalent method of the SQLHelper class defined in the Data Access
Application Block.

Take a look at
http://www.microsoft.com/resources/p...iences.asp#dev

Scroll down a ways, and you'll find a link to the Data Access Application
Block, as well as a wealth of other useful information.

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP for some time, but getting data out of a SQL database and displaying a single value
eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where code = 0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")

to get a record out of the database. All I want to do now put the Name in
that record into a variable and use it in the HTML text. I would appreciate any help.

Thank you
Hermann

Nov 18 '05 #6
Hi

Thanks for your help. The code example comes straight out of a tutorial on
asp.net!

Unfortunately, I do not at this time have the leisure to learn the ins and
outs of the .net methods. All I need is the equivalent code to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"

Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset

code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")

I would be very thankful if someone could help me write a the code to do the
same thing under .net.

Thanks
Hermann

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP for some time, but getting data out of a SQL database and displaying a single value
eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where code = 0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")

to get a record out of the database. All I want to do now put the Name in
that record into a variable and use it in the HTML text. I would appreciate any help.

Thank you
Hermann

Nov 18 '05 #7
Hello Hermann,

SqlConnection myConnection = new SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial Catalog=database;");

SqlCommand cmd = new SqlCommand("select name from products where code = 0117", myConnection);

using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection) )
{
rdr.Read(); // if you want to loop through records, sorround this with a while block

string code = rdr["code"].ToString();
string title = rdr["title"].ToString();
string url = rdr["url"].ToString();
string email = rdr["email"].ToString();
string description = rdr["description"].ToString();
string retlink = rdr["retlink"].ToString();
}
Hi

Thanks for your help. The code example comes straight out of a
tutorial on asp.net!

Unfortunately, I do not at this time have the leisure to learn the ins
and outs of the .net methods. All I need is the equivalent code to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"
Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset
code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")
I would be very thankful if someone could help me write a the code to
do the same thing under .net.

Thanks
Hermann
"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP
for

some
time, but getting data out of a SQL database and displaying a single
value eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where
code

=
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")
to get a record out of the database. All I want to do now put the
Name in that record into a variable and use it in the HTML text. I
would

appreciate
any help.

Thank you
Hermann

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #8
Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:

Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot be
used as an expression

I have the following lines at the top of the page:

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>

Do I need to add anything else?
Thanks again
Hermann

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Hello Hermann,

SqlConnection myConnection = new SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");
SqlCommand cmd = new SqlCommand("select name from products where code = 0117", myConnection);
using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection) ) {
rdr.Read(); // if you want to loop through records, sorround this with a while block
string code = rdr["code"].ToString();
string title = rdr["title"].ToString();
string url = rdr["url"].ToString();
string email = rdr["email"].ToString();
string description = rdr["description"].ToString();
string retlink = rdr["retlink"].ToString();
}
Hi

Thanks for your help. The code example comes straight out of a
tutorial on asp.net!

Unfortunately, I do not at this time have the leisure to learn the ins
and outs of the .net methods. All I need is the equivalent code to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"
Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset
code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")
I would be very thankful if someone could help me write a the code to
do the same thing under .net.

Thanks
Hermann
"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP
for

some
time, but getting data out of a SQL database and displaying a single
value eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products where
code

=
0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")
to get a record out of the database. All I want to do now put the
Name in that record into a variable and use it in the HTML text. I
would

appreciate
any help.

Thank you
Hermann

--

--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #9
Hello Hermann,

Try putting this in the .cs code-behind file in Page_Load.
Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:
Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
be used as an expression

I have the following lines at the top of the page:

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
Do I need to add anything else?
Thanks again
Hermann
"Matt Berther" <mb******@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Hello Hermann,

SqlConnection myConnection = new

SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");
SqlCommand cmd = new SqlCommand("select name from products where code
=

0117", myConnection);
using (IDataReader rdr =

cmd.ExecuteReader(CommandBehavior.CloseConnection) )
{
rdr.Read(); // if you want to loop through records, sorround this
with

a while block
string code = rdr["code"].ToString();
string title = rdr["title"].ToString();
string url = rdr["url"].ToString();
string email = rdr["email"].ToString();
string description = rdr["description"].ToString();
string retlink = rdr["retlink"].ToString();
}
Hi

Thanks for your help. The code example comes straight out of a
tutorial on asp.net!

Unfortunately, I do not at this time have the leisure to learn the
ins and outs of the .net methods. All I need is the equivalent code
to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"
Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset
code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")
I would be very thankful if someone could help me write a the code
to
do the same thing under .net.
Thanks
Hermann
"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
Hi

I need help at the very beginning. I have been writing classic ASP
for

some

time, but getting data out of a SQL database and displaying a
single value eludes me.

So far I have the following code:

Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
Source=SQLServer;Initial Catalog=database;")
Dim myCommand As New SqlDataAdapter("select Name from Products
where
code
=

0117", myConnection)

Dim ds As New DataSet()
myCommand.Fill(ds, "Name")
to get a record out of the database. All I want to do now put the
Name in that record into a variable and use it in the HTML text. I
would
appreciate

any help.

Thank you
Hermann

--

--
Matt Berther
http://www.mattberther.com

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #10
Hi

Can you explain what you mean with "Page_Load"?
Thanks
Hermann

"Matt Berther" <mb******@hotmail.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello Hermann,

Try putting this in the .cs code-behind file in Page_Load.
Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:
Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
be used as an expression

I have the following lines at the top of the page:

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
Do I need to add anything else?
Thanks again
Hermann
"Matt Berther" <mb******@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
Hello Hermann,

SqlConnection myConnection = new

SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");
SqlCommand cmd = new SqlCommand("select name from products where code
=

0117", myConnection);
using (IDataReader rdr =

cmd.ExecuteReader(CommandBehavior.CloseConnection) )
{
rdr.Read(); // if you want to loop through records, sorround this
with

a while block
string code = rdr["code"].ToString();
string title = rdr["title"].ToString();
string url = rdr["url"].ToString();
string email = rdr["email"].ToString();
string description = rdr["description"].ToString();
string retlink = rdr["retlink"].ToString();
}
Hi

Thanks for your help. The code example comes straight out of a
tutorial on asp.net!

Unfortunately, I do not at this time have the leisure to learn the
ins and outs of the .net methods. All I need is the equivalent code
to:

Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "dbname","username","password"
Query = "Select * from links Where ID = '" & id & "'"
Set RS = Connect.Execute(Query) <-- I thought this is the dataset
code = RS("code")
title = RS("title")
url = RS("url")
email = RS("email")
description = RS("description")
retlink = RS("retlink")
I would be very thankful if someone could help me write a the code
to
do the same thing under .net.
Thanks
Hermann
"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:us*************@TK2MSFTNGP11.phx.gbl...
> Hi
>
> I need help at the very beginning. I have been writing classic ASP
> for
>
some

> time, but getting data out of a SQL database and displaying a
> single value eludes me.
>
> So far I have the following code:
>
> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
> Source=SQLServer;Initial Catalog=database;")
> Dim myCommand As New SqlDataAdapter("select Name from Products
> where
> code
=

> 0117", myConnection)
>
> Dim ds As New DataSet()
> myCommand.Fill(ds, "Name")
> to get a record out of the database. All I want to do now put the
> Name in that record into a variable and use it in the HTML text. I
> would
appreciate

> any help.
>
> Thank you
> Hermann
--

--
Matt Berther
http://www.mattberther.com

--

--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #11
there is a Page_Load event, which you can implement. I believe he wants you
to put the code he provided into that event handler.

private void Page_Load (object sender, System.EventArgs e)
{
// your code here
}

this is part of the 'code behind' technology in ASP.net.

hope that helps,
sincerely,
J

"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
Hi

Can you explain what you mean with "Page_Load"?
Thanks
Hermann

"Matt Berther" <mb******@hotmail.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello Hermann,

Try putting this in the .cs code-behind file in Page_Load.
Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:
Compiler Error Message: BC30684: 'SqlConnection' is a type and cannot
be used as an expression

I have the following lines at the top of the page:

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
Do I need to add anything else?
Thanks again
Hermann
"Matt Berther" <mb******@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...

> Hello Hermann,
>
> SqlConnection myConnection = new
>
SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");

> SqlCommand cmd = new SqlCommand("select name from products where code
> =
>
0117", myConnection);

> using (IDataReader rdr =
>
cmd.ExecuteReader(CommandBehavior.CloseConnection) )

> {
> rdr.Read(); // if you want to loop through records, sorround this
> with
a while block

> string code = rdr["code"].ToString();
> string title = rdr["title"].ToString();
> string url = rdr["url"].ToString();
> string email = rdr["email"].ToString();
> string description = rdr["description"].ToString();
> string retlink = rdr["retlink"].ToString();
> }
>> Hi
>>
>> Thanks for your help. The code example comes straight out of a
>> tutorial on asp.net!
>>
>> Unfortunately, I do not at this time have the leisure to learn the
>> ins and outs of the .net methods. All I need is the equivalent code
>> to:
>>
>> Set Connect = Server.CreateObject("ADODB.Connection")
>> Connect.Open "dbname","username","password"
>> Query = "Select * from links Where ID = '" & id & "'"
>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
>> code = RS("code")
>> title = RS("title")
>> url = RS("url")
>> email = RS("email")
>> description = RS("description")
>> retlink = RS("retlink")
>> I would be very thankful if someone could help me write a the code
>> to
>> do the same thing under .net.
>> Thanks
>> Hermann
>> "Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
>> news:us*************@TK2MSFTNGP11.phx.gbl...
>>> Hi
>>>
>>> I need help at the very beginning. I have been writing classic ASP
>>> for
>>>
>> some
>>
>>> time, but getting data out of a SQL database and displaying a
>>> single value eludes me.
>>>
>>> So far I have the following code:
>>>
>>> Dim myConnection As New SqlConnection("UID=dbuser;PWD=thepass;Data
>>> Source=SQLServer;Initial Catalog=database;")
>>> Dim myCommand As New SqlDataAdapter("select Name from Products
>>> where
>>> code
>> =
>>
>>> 0117", myConnection)
>>>
>>> Dim ds As New DataSet()
>>> myCommand.Fill(ds, "Name")
>>> to get a record out of the database. All I want to do now put the
>>> Name in that record into a variable and use it in the HTML text. I
>>> would
>> appreciate
>>
>>> any help.
>>>
>>> Thank you
>>> Hermann
> --
>
> --
> Matt Berther
> http://www.mattberther.com

--

--
Matt Berther
http://www.mattberther.com


Nov 18 '05 #12
Hello John,

Thanks. That is exactly what I meant...
there is a Page_Load event, which you can implement. I believe he
wants you to put the code he provided into that event handler.

private void Page_Load (object sender, System.EventArgs e)
{
// your code here
}
this is part of the 'code behind' technology in ASP.net.

hope that helps,
sincerely,
J
"Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
news:eQ**************@TK2MSFTNGP10.phx.gbl...
Hi

Can you explain what you mean with "Page_Load"?
Thanks
Hermann
"Matt Berther" <mb******@hotmail.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hello Hermann,

Try putting this in the .cs code-behind file in Page_Load.

Hi
Much Thanks for the code. I placed on a test page with the correct
variables, but received this error message:
Compiler Error Message: BC30684: 'SqlConnection' is a type and
cannot
be used as an expression
I have the following lines at the top of the page:

<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
Do I need to add anything else?
Thanks again
Hermann
"Matt Berther" <mb******@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl...
> Hello Hermann,
>
> SqlConnection myConnection = new
>
SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
Catalog=database;");

> SqlCommand cmd = new SqlCommand("select name from products where
> code =
>
0117", myConnection);

> using (IDataReader rdr =
>
cmd.ExecuteReader(CommandBehavior.CloseConnection) )

> {
> rdr.Read(); // if you want to loop through records, sorround this
> with
a while block

> string code = rdr["code"].ToString();
> string title = rdr["title"].ToString();
> string url = rdr["url"].ToString();
> string email = rdr["email"].ToString();
> string description = rdr["description"].ToString();
> string retlink = rdr["retlink"].ToString();
> }
>> Hi
>>
>> Thanks for your help. The code example comes straight out of a
>> tutorial on asp.net!
>>
>> Unfortunately, I do not at this time have the leisure to learn
>> the ins and outs of the .net methods. All I need is the
>> equivalent code to:
>>
>> Set Connect = Server.CreateObject("ADODB.Connection")
>> Connect.Open "dbname","username","password"
>> Query = "Select * from links Where ID = '" & id & "'"
>> Set RS = Connect.Execute(Query) <-- I thought this is the dataset
>> code = RS("code")
>> title = RS("title")
>> url = RS("url")
>> email = RS("email")
>> description = RS("description")
>> retlink = RS("retlink")
>> I would be very thankful if someone could help me write a the
>> code
>> to
>> do the same thing under .net.
>> Thanks
>> Hermann
>> "Hermann W Ehlers" <he*****@AThawkspoint.com> wrote in message
>> news:us*************@TK2MSFTNGP11.phx.gbl...
>>> Hi
>>>
>>> I need help at the very beginning. I have been writing classic
>>> ASP for
>>>
>> some
>>
>>> time, but getting data out of a SQL database and displaying a
>>> single value eludes me.
>>>
>>> So far I have the following code:
>>>
>>> Dim myConnection As New
>>> SqlConnection("UID=dbuser;PWD=thepass;Data
>>> Source=SQLServer;Initial Catalog=database;")
>>> Dim myCommand As New SqlDataAdapter("select Name from Products
>>> where
>>> code
>> =
>>
>>> 0117", myConnection)
>>>
>>> Dim ds As New DataSet()
>>> myCommand.Fill(ds, "Name")
>>> to get a record out of the database. All I want to do now put
>>> the
>>> Name in that record into a variable and use it in the HTML text.
>>> I
>>> would
>> appreciate
>>
>>> any help.
>>>
>>> Thank you
>>> Hermann
> --
>
> --
> Matt Berther
> http://www.mattberther.com
--

--
Matt Berther
http://www.mattberther.com

--

--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Damien | last post by:
I have just built a simple stopwatch application, but when i f5 to get things goings i get this message, An unhandled exception of type 'System.ArithmeticException' occurred in...
0
by: Pete | last post by:
Hi All, A total Newby with, possibly, a daft question? However, until I can get a reasonable explanation I am disinclined towards going further. Here goes: I recently downloaded the latest...
8
by: Ask | last post by:
G'day All, Just thought I'd drop in and say hi. I'm new to Python, but old to software development. Python is one of the languages used in my new job, so I've just bought a book, read it, and...
10
by: Fred Nelson | last post by:
Hi: I have programmed in VB.NET for about a year and I'm in the process of learing C#. I'm really stuck on this question - and I know it's a "newby" question: In VB.NET I have several...
4
by: Fred Nelson | last post by:
I have an applicatioin that I'm writing that uses a "case" file that contains over 350 columns and more may be added in the future. I would like to create a dataset with all the column names and...
4
by: Fred Nelson | last post by:
Hi: I'm developing a web application that needs to have five values, each retrieved from cookies on many pages. If I have five "Request.Cookies" commands together does this cause five "round...
2
by: Fred Nelson | last post by:
Hi: I'm working on a VS2005 web application and I have what is probabably a "newby" question. In VS2003 I could drag a textbox/button/etc on to a form and position it with the mouse. I...
2
by: johnnyG | last post by:
Greetings, I'm studying for the 70-330 Exam using the MS Press book by Tony Northrup and there are 2 side-by-side examples of using the SHA1CryptoServiceProvider to create a hash value from a...
10
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in...
5
by: alexrixhardson | last post by:
Hi guys, I am a newby in the C/C++ world, and I am beginning to work on a rather simple TCP/IP proxy application which must be able to handle large volume of data as quickly as possible. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.