By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,510 Members | 1,821 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,510 IT Pros & Developers. It's quick & easy.

Newby question

P: n/a
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
Share this Question
Share on Google+
12 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.