Showing posts with label hii. Show all posts
Showing posts with label hii. Show all posts

Thursday, March 29, 2012

Newbie: How safe is source code?

Hi

I am a complete newbie and am contemplating moving to asp.net from asp. How
protected is an asp.net web site source code should it be delivered to a
client?

Thanks

RegardsMy opinion:

If your concern is about protecting access to the code itself, then ASP.NET
source is much safer than classic ASP, because the deliverable is actually a
set of compiled .dll's, rather than a set of vbscript files.

However, you should be aware that it is notoriously easy to decompile a .NET
assembly into very clean source code. If this worries you, you should
consider using an obfuscator to "scramble" the dll code so that decompiling
either doesn't work or doesn't work very well.

-Michael

"John" <john@.nospam.infovis.co.uk> wrote in message
news:Oo1BKKIpDHA.2732@.TK2MSFTNGP11.phx.gbl...
> Hi
> I am a complete newbie and am contemplating moving to asp.net from asp.
How
> protected is an asp.net web site source code should it be delivered to a
> client?
> Thanks
> Regards
Hi John,

You should obfuscate your ASP.NET with Dotfuscator (a .NET
obfuscator).
A lite version is included inside VS.NET 2003 under the tools menu.
This will make reverse engineered code harder to understand.

If you want more protection that significantly hinders reverse
engineering by crashing or stopping decompilers and support look at
Dotfuscator Professional Edition.

For more info: www.preemptive.com/dotfuscator

Best Regards,
Dotfuscator Team

> "John" <john@.nospam.infovis.co.uk>
> > Hi
> > I am a complete newbie and am contemplating moving to asp.net from asp.
> How
> > protected is an asp.net web site source code should it be delivered to a
> > client?
I agree. But what about 'Whidbey' (new VS 2004)? I think we going
back to no code-behind'.

-----------------------
http://www.naptaxes.com/AAJ/
[AllAmericanJobs - Searching jobs from your desktop and automatically
sends resume.]
Even with 'no code behind' isn't the result still .NET code which can be decompiled?

> I agree. But what about 'Whidbey' (new VS 2004)? I think we going
> back to ?no code-behind'.

Newbie: How to start

Hi

I have a html page with a form. How can I start turning this into an asp.net
page to including validation and submit processing?

Thanks

Regards

YahyaHey,
Well first things first. Create a web project if you are using Visual
Studio. If not .. you will need to work a bit more and create a virtual
directory and an aspx page. Similar to a normal html page but with lot of
extra tags... Get yourself a good asp.net book.
Now copy the html body and paste it in the aspx file. When you double a html
object like button or image it will be converted to equivalent web control
Have fun learning.. its fun..

Hermit Dave

"John" <john@.nospam.infovis.co.uk> wrote in message
news:%23neTBVQvDHA.2464@.TK2MSFTNGP12.phx.gbl...
> Hi
> I have a html page with a form. How can I start turning this into an
asp.net
> page to including validation and submit processing?
> Thanks
> Regards
>
> Yahya

Saturday, March 24, 2012

NEWBIE: RecordCount of SqlDataSource

Hi!

I have this SqlSataSource (aspx 2.0):

<asp:SqlDataSource ID="ArtiestenSource" Runat="server"
SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
dbo.muziek GROUP BY artiest"
ConnectionString="Server=DESERVER;User
ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
ProviderName="System.Data.SqlClient">
</asp:SqlDataSource
Maybe someone knows how to retrieve the number of rows of this datasource?
(ArtiestenSource.RecordCount doesn't work. )

Also: I would display this number of rows like this:
<% response.write(ArtiestenSource.RecordCount) %
But I don't doubt there is a typical dot net 2.0 way of displaying this
result. (So, something else then <% response.write() %>.
If I am right about that, does someone know what right way is?

Thanks!

DaanYou should be able to extract the DataSet and pull the number out (would
give you code, but I do not have the 2.0 machine up and running). As far as
how to embed the number in a page, you have two choices.

1. Add a label and set the Text property
2. Use data binding <%# =variableName %> - just set the variableName in the
back and make sure it is accessible. You will have to run Page.DataBind() to
ensure it is bound, however.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Daan" <daan@.nergens.com> wrote in message
news:cdql5b$uat$1@.news.cistron.nl...
> Hi!
> I have this SqlSataSource (aspx 2.0):
> <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
> albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> dbo.muziek GROUP BY artiest"
> ConnectionString="Server=DESERVER;User
> ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> ProviderName="System.Data.SqlClient">
> </asp:SqlDataSource>
> Maybe someone knows how to retrieve the number of rows of this datasource?
> (ArtiestenSource.RecordCount doesn't work. )
> Also: I would display this number of rows like this:
> <% response.write(ArtiestenSource.RecordCount) %>
> But I don't doubt there is a typical dot net 2.0 way of displaying this
> result. (So, something else then <% response.write() %>.
> If I am right about that, does someone know what right way is?
> Thanks!
> Daan
Hi!
Does anyone know how to extract the DataSet from a SqlDataSource?
(I have really been searching and trying, but I can't figger it out -> a
real newbie?)

Thanks!

Daan

"Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> You should be able to extract the DataSet and pull the number out (would
> give you code, but I do not have the 2.0 machine up and running). As far
as
> how to embed the number in a page, you have two choices.
> 1. Add a label and set the Text property
> 2. Use data binding <%# =variableName %> - just set the variableName in
the
> back and make sure it is accessible. You will have to run Page.DataBind()
to
> ensure it is bound, however.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ************************************************
> Think Outside the Box!
> ************************************************
> "Daan" <daan@.nergens.com> wrote in message
> news:cdql5b$uat$1@.news.cistron.nl...
> > Hi!
> > I have this SqlSataSource (aspx 2.0):
> > <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> > SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album)
AS
> > albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> > CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> > dbo.muziek GROUP BY artiest"
> > ConnectionString="Server=DESERVER;User
> > ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> > ProviderName="System.Data.SqlClient">
> > </asp:SqlDataSource>
> > Maybe someone knows how to retrieve the number of rows of this
datasource?
> > (ArtiestenSource.RecordCount doesn't work. )
> > Also: I would display this number of rows like this:
> > <% response.write(ArtiestenSource.RecordCount) %>
> > But I don't doubt there is a typical dot net 2.0 way of displaying this
> > result. (So, something else then <% response.write() %>.
> > If I am right about that, does someone know what right way is?
> > Thanks!
> > Daan
Daan:

Here is another way to get the record count: The SqlDataSource has an event
called "Selected." It passes in a SqlDataSourceStatusEventArgs, which has a
property called "AffectedRows." I just tried hooking this event after calling
a simple select to the Products table of Northwinds and got the rowcount.

Chuck

"Daan" wrote:

> Hi!
> Does anyone know how to extract the DataSet from a SqlDataSource?
> (I have really been searching and trying, but I can't figger it out -> a
> real newbie?)
> Thanks!
> Daan
>
>
> "Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
> schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> > You should be able to extract the DataSet and pull the number out (would
> > give you code, but I do not have the 2.0 machine up and running). As far
> as
> > how to embed the number in a page, you have two choices.
> > 1. Add a label and set the Text property
> > 2. Use data binding <%# =variableName %> - just set the variableName in
> the
> > back and make sure it is accessible. You will have to run Page.DataBind()
> to
> > ensure it is bound, however.
> > --
> > Gregory A. Beamer
> > MVP; MCP: +I, SE, SD, DBA
> > ************************************************
> > Think Outside the Box!
> > ************************************************
> > "Daan" <daan@.nergens.com> wrote in message
> > news:cdql5b$uat$1@.news.cistron.nl...
> > > Hi!
> > > > I have this SqlSataSource (aspx 2.0):
> > > > <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> > > SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album)
> AS
> > > albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> > > CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> > > dbo.muziek GROUP BY artiest"
> > > ConnectionString="Server=DESERVER;User
> > > ID=sa;Password=wachtwoord;Database=Muziek;Persist Security Info=True"
> > > ProviderName="System.Data.SqlClient">
> > > </asp:SqlDataSource>
> > > > Maybe someone knows how to retrieve the number of rows of this
> datasource?
> > > (ArtiestenSource.RecordCount doesn't work. )
> > > > Also: I would display this number of rows like this:
> > > <% response.write(ArtiestenSource.RecordCount) %>
> > > > But I don't doubt there is a typical dot net 2.0 way of displaying this
> > > result. (So, something else then <% response.write() %>.
> > > If I am right about that, does someone know what right way is?
> > > > Thanks!
> > > > Daan
> > >

NEWBIE: RecordCount of SqlDataSource

Hi!
I have this SqlSataSource (aspx 2.0):
<asp:SqlDataSource ID="ArtiestenSource" Runat="server"
SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
dbo.muziek GROUP BY artiest"
ConnectionString="Server=DESERVER;User
ID=sa;Password=wachtwoord;Database=Muzie
k;Persist Security Info=True"
ProviderName="System.Data.SqlClient">
</asp:SqlDataSource>
Maybe someone knows how to retrieve the number of rows of this datasource?
(ArtiestenSource.RecordCount doesn't work. )
Also: I would display this number of rows like this:
<% response.write(ArtiestenSource.RecordCount) %>
But I don't doubt there is a typical dot net 2.0 way of displaying this
result. (So, something else then <% response.write() %>.
If I am right about that, does someone know what right way is?
Thanks!
DaanYou should be able to extract the DataSet and pull the number out (would
give you code, but I do not have the 2.0 machine up and running). As far as
how to embed the number in a page, you have two choices.
1. Add a label and set the Text property
2. Use data binding <%# =variableName %> - just set the variableName in the
back and make sure it is accessible. You will have to run Page.DataBind() to
ensure it is bound, however.
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
****************************************
********
Think Outside the Box!
****************************************
********
"Daan" <daan@.nergens.com> wrote in message
news:cdql5b$uat$1@.news.cistron.nl...
> Hi!
> I have this SqlSataSource (aspx 2.0):
> <asp:SqlDataSource ID="ArtiestenSource" Runat="server"
> SelectCommand="SELECT lower(artiest) AS artiest, COUNT(DISTINCT album) AS
> albums, COUNT(artiest) AS tracks, SUM(seconden) AS seconden,
> CONVERT(varchar, DATEADD(second, SUM(seconden), ''), 108) AS Duur FROM
> dbo.muziek GROUP BY artiest"
> ConnectionString="Server=DESERVER;User
> ID=sa;Password=wachtwoord;Database=Muzie
k;Persist Security Info=True"
> ProviderName="System.Data.SqlClient">
> </asp:SqlDataSource>
> Maybe someone knows how to retrieve the number of rows of this datasource?
> (ArtiestenSource.RecordCount doesn't work. )
> Also: I would display this number of rows like this:
> <% response.write(ArtiestenSource.RecordCount) %>
> But I don't doubt there is a typical dot net 2.0 way of displaying this
> result. (So, something else then <% response.write() %>.
> If I am right about that, does someone know what right way is?
> Thanks!
> Daan
>
Hi!
Does anyone know how to extract the DataSet from a SqlDataSource?
(I have really been searching and trying, but I can't figger it out -> a
real newbie?)
Thanks!
Daan
"Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> You should be able to extract the DataSet and pull the number out (would
> give you code, but I do not have the 2.0 machine up and running). As far
as
> how to embed the number in a page, you have two choices.
> 1. Add a label and set the Text property
> 2. Use data binding <%# =variableName %> - just set the variableName in
the
> back and make sure it is accessible. You will have to run Page.DataBind()
to
> ensure it is bound, however.
> --
> Gregory A. Beamer
> MVP; MCP: +I, SE, SD, DBA
> ****************************************
********
> Think Outside the Box!
> ****************************************
********
> "Daan" <daan@.nergens.com> wrote in message
> news:cdql5b$uat$1@.news.cistron.nl...
AS
datasource?
>
Daan:
Here is another way to get the record count: The SqlDataSource has an event
called "Selected." It passes in a SqlDataSourceStatusEventArgs, which has a
property called "AffectedRows." I just tried hooking this event after callin
g
a simple select to the Products table of Northwinds and got the rowcount.
Chuck
"Daan" wrote:

> Hi!
> Does anyone know how to extract the DataSet from a SqlDataSource?
> (I have really been searching and trying, but I can't figger it out -> a
> real newbie?)
> Thanks!
> Daan
>
>
> "Cowboy (Gregory A. Beamer) [MVP]" <NoSpamMgbworld@.comcast.netNoSpamM>
> schreef in bericht news:%231cgHrLcEHA.1656@.TK2MSFTNGP09.phx.gbl...
> as
> the
> to
> AS
> datasource?
>
>

Newbie: Where to start

Hi

I have an asp background. I need to start a long term project with access
backend that would be evolved over a period of time. A flexible and easily
extensible infrastructure is highly desirable. Is there a site that I can
use as model of good practices or a template that I can start with?

Thanks

Regardshttp://www.asp.net/Default.aspx?tabindex=0&tabid=1

"John" <john@.nospam.infovis.co.uk> wrote in message
news:OQ8QxxOwDHA.1740@.TK2MSFTNGP09.phx.gbl...
> Hi
> I have an asp background. I need to start a long term project with access
> backend that would be evolved over a period of time. A flexible and easily
> extensible infrastructure is highly desirable. Is there a site that I can
> use as model of good practices or a template that I can start with?
> Thanks
> Regards
Hi

I am using vs.net 2003 to develop in vb.net. I just don't know how to
structure a good asp.net app as it would be my first. I need to know how to
implement modularity in asp.net so things can be extended easily as the app
develops. Also any tips on saving time on development/maintenance by using
things like templates etc.

Thanks

Regards

"TJS" <nospam@.here.com> wrote in message
news:OwAA3PPwDHA.1088@.tk2msftngp13.phx.gbl...
> http://www.asp.net/Default.aspx?tabindex=0&tabid=1
>
> "John" <john@.nospam.infovis.co.uk> wrote in message
> news:OQ8QxxOwDHA.1740@.TK2MSFTNGP09.phx.gbl...
> > Hi
> > I have an asp background. I need to start a long term project with
access
> > backend that would be evolved over a period of time. A flexible and
easily
> > extensible infrastructure is highly desirable. Is there a site that I
can
> > use as model of good practices or a template that I can start with?
> > Thanks
> > Regards
Thats a lot to be requesting advice on given your on about moving to an OO
based approach.

I woudl strongly suggest that you buy a book to assist you.

Try
http://aspalliance.com/cookbook/default.aspx

Or Dino Esposito's Programming Microsoft ASP.NET

--
Regards

John Timney (Microsoft ASP.NET MVP)
--------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
--------------

"John" <john@.nospam.infovis.co.uk> wrote in message
news:#sSeyZPwDHA.2440@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using vs.net 2003 to develop in vb.net. I just don't know how to
> structure a good asp.net app as it would be my first. I need to know how
to
> implement modularity in asp.net so things can be extended easily as the
app
> develops. Also any tips on saving time on development/maintenance by using
> things like templates etc.
> Thanks
> Regards
>
> "TJS" <nospam@.here.com> wrote in message
> news:OwAA3PPwDHA.1088@.tk2msftngp13.phx.gbl...
> > http://www.asp.net/Default.aspx?tabindex=0&tabid=1
> > "John" <john@.nospam.infovis.co.uk> wrote in message
> > news:OQ8QxxOwDHA.1740@.TK2MSFTNGP09.phx.gbl...
> > > Hi
> > > > I have an asp background. I need to start a long term project with
> access
> > > backend that would be evolved over a period of time. A flexible and
> easily
> > > extensible infrastructure is highly desirable. Is there a site that I
> can
> > > use as model of good practices or a template that I can start with?
> > > > Thanks
> > > > Regards
> >
Yes, templates can be used with ASP.net

To incorporate modularity build your code in classes.

--
================================
http://www.ASPkey.net/
A Resource Site for Web Developers
*Free OnLine web Tools
*Free development services
================================

"John" <john@.nospam.infovis.co.uk> wrote in message
news:%23sSeyZPwDHA.2440@.TK2MSFTNGP12.phx.gbl...
> Hi
> I am using vs.net 2003 to develop in vb.net. I just don't know how to
> structure a good asp.net app as it would be my first. I need to know how
to
> implement modularity in asp.net so things can be extended easily as the
app
> develops. Also any tips on saving time on development/maintenance by using
> things like templates etc.
> Thanks
> Regards
>
> "TJS" <nospam@.here.com> wrote in message
> news:OwAA3PPwDHA.1088@.tk2msftngp13.phx.gbl...
> > http://www.asp.net/Default.aspx?tabindex=0&tabid=1
> > "John" <john@.nospam.infovis.co.uk> wrote in message
> > news:OQ8QxxOwDHA.1740@.TK2MSFTNGP09.phx.gbl...
> > > Hi
> > > > I have an asp background. I need to start a long term project with
> access
> > > backend that would be evolved over a period of time. A flexible and
> easily
> > > extensible infrastructure is highly desirable. Is there a site that I
> can
> > > use as model of good practices or a template that I can start with?
> > > > Thanks
> > > > Regards
> >

Thursday, March 22, 2012

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
HermannFirst 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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
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
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" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.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
You're right. I didn't catch that one at all. I guess that's why variable
naming is so important.

Dale

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:OQF5$FAMEHA.140@.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" <hermann@.AThawkspoint.com> wrote in message
> > news:usvpno9LEHA.340@.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
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/...diences.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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
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" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.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
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" <mberther@.hotmail.com> wrote in message
news:ONNBoITMEHA.2532@.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" <hermann@.AThawkspoint.com> wrote in message
> > news:usvpno9LEHA.340@.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
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" <mberther@.hotmail.com> wrote in message
> news:ONNBoITMEHA.2532@.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" <hermann@.AThawkspoint.com> wrote in message
>>> news:usvpno9LEHA.340@.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
Hi

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

"Matt Berther" <mberther@.hotmail.com> wrote in message
news:%23C6uZOaMEHA.644@.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" <mberther@.hotmail.com> wrote in message
> > news:ONNBoITMEHA.2532@.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" <hermann@.AThawkspoint.com> wrote in message
> >>> news:usvpno9LEHA.340@.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
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" <hermann@.AThawkspoint.com> wrote in message
news:eQCc71jMEHA.3972@.TK2MSFTNGP10.phx.gbl...
> Hi
> Can you explain what you mean with "Page_Load"?
> Thanks
> Hermann
> "Matt Berther" <mberther@.hotmail.com> wrote in message
> news:%23C6uZOaMEHA.644@.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" <mberther@.hotmail.com> wrote in message
> > > news:ONNBoITMEHA.2532@.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" <hermann@.AThawkspoint.com> wrote in message
> > >>> news:usvpno9LEHA.340@.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
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" <hermann@.AThawkspoint.com> wrote in message
> news:eQCc71jMEHA.3972@.TK2MSFTNGP10.phx.gbl...
>> Hi
>>
>> Can you explain what you mean with "Page_Load"?
>> Thanks
>> Hermann
>> "Matt Berther" <mberther@.hotmail.com> wrote in message
>> news:%23C6uZOaMEHA.644@.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" <mberther@.hotmail.com> wrote in message
>>>> news:ONNBoITMEHA.2532@.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" <hermann@.AThawkspoint.com> wrote in message
>>>>>> news:usvpno9LEHA.340@.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

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
HermannFirst 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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
>
Hello Hermann,
An dataset is probably complete overkill for what you're trying to accomplis
h 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 cas
t it to the appropriate type.
HTH,
Matt Berther
http://www.mattberther.com
Hello DalePres,
Dale, in his code example, he was creating a SqlDataAdapter. The variable na
me 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" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>
> some
>
> =
>
> appreciate
>
--
Matt Berther
http://www.mattberther.com
You're right. I didn't catch that one at all. I guess that's why variable
naming is so important.
Dale
"Matt Berther" <mberther@.hotmail.com> wrote in message
news:OQF5$FAMEHA.140@.TK2MSFTNGP09.phx.gbl...
> Hello DalePres,
> Dale, in his code example, he was creating a SqlDataAdapter. The variable
name was just wrong. ;)
>
> --
> --
> Matt Berther
> http://www.mattberther.com
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/...diences.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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
>
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" <hermann@.AThawkspoint.com> wrote in message
news:usvpno9LEHA.340@.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
>
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 whi
le 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" <hermann@.AThawkspoint.com> wrote in message
> news:usvpno9LEHA.340@.TK2MSFTNGP11.phx.gbl...
>
> some
>
> =
>
> appreciate
>
--
Matt Berther
http://www.mattberther.com
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" <mberther@.hotmail.com> wrote in message
news:ONNBoITMEHA.2532@.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();
> }
>
> --
> --
> Matt Berther
> http://www.mattberther.com
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" <mberther@.hotmail.com> wrote in message
> news:ONNBoITMEHA.2532@.TK2MSFTNGP10.phx.gbl...
>
> SqlConnection("UID=dbuser;PWD=thepass;Data Source=server;Initial
> Catalog=database;");
>
> 0117", myConnection);
>
> cmd.ExecuteReader(CommandBehavior.CloseConnection))
>
> a while block
>
--
Matt Berther
http://www.mattberther.com

Newby Question Linking of data between HTML and ASP!

Hi:

I am an utter virgin at ASP, but have experience in HTML!

I have a very basic question.

I have an ASP sheet, where I wish to permit the user to enter a code, and then return the
results of a query against a table, using that code. My problem is that I don't quite know
how to:

A Present the end user input to the query
B. Present the results to the HTML: code.

In the query I have tried common sql techniques such as "Like{Input the code]", but that
does not work.

I know there must be an easy way, but it too simple to show up in the materials I am
reading.

Can someone point me in the direction of an answer.

Thanks

John Baker> Can someone point me in the direction of an answer.

You can find an answer on the ASP ewsgroups:

microsoft.public.inetserver.asp.db
microsoft.public.inetserver.asp.general

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"John Baker" <Baker.JH@.Verizon.net> wrote in message
news:cccf01dcm7rb7khonngaqa95qv2o8n15sh@.4ax.com...
> Hi:
> I am an utter virgin at ASP, but have experience in HTML!
> I have a very basic question.
> I have an ASP sheet, where I wish to permit the user to enter a code, and
> then return the
> results of a query against a table, using that code. My problem is that I
> don't quite know
> how to:
> A Present the end user input to the query
> B. Present the results to the HTML: code.
> In the query I have tried common sql techniques such as "Like{Input the
> code]", but that
> does not work.
> I know there must be an easy way, but it too simple to show up in the
> materials I am
> reading.
> Can someone point me in the direction of an answer.
> Thanks
> John Baker
Kevin:

Unfortunately Verizon does not offer them.

Any other alternatives?

John
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote:

>microsoft.public.inetserver.asp.general
This is a newsgroup. If you have Outlook Express, you have a news reader.
Using Outlook Experss's newsreader, go to the msnews.microsoft.com news
server and you'll find all of the Microsoft newsgroups.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"John Baker" <Baker.JH@.Verizon.net> wrote in message
news:r2rf015ek9aq5rc9kj82ra9vgll0t6fe4u@.4ax.com...
> Kevin:
> Unfortunately Verizon does not offer them.
> Any other alternatives?
> John
> "Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> wrote:
>>microsoft.public.inetserver.asp.general

Friday, March 16, 2012

Newline detected when add script in C# (ASP.NET)

Hi!

I'm trying to add script to the page and place following code in my ascx
(control):

Page.RegisterClientScriptBlock("adder", "<script>function
doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
eval(document.all.TextBox2.value)}</script>");

It doesn't work giving me all kind of problems...

I suspect the problem is with <> charachters.

How do I go around this problem?

Also, placing this line in code (I use WebMatrix) will mess up all HTML
code??

Thanks!If that is the exact line from your code, then it just has to do with how
your formed your string. You cannot insert a line break in a string in C#.
It should work if you change your code to read:

Page.RegisterClientScriptBlock("adder", "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>");

or, for more readability, I always for my javascript in a temp variable
first. Just kinda hard to read otherwise

string script = "<script>function " +
"doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
" +
"eval(document.all.TextBox2.value)}</script>"
Page.RegisterClientScriptBlock("adder", script);

either way, both of those should work for you.

-Cliff

"Ivan Demkovitch" <i@.a.b> wrote in message
news:OfydJF8oDHA.976@.tk2msftngp13.phx.gbl...
> Hi!
> I'm trying to add script to the page and place following code in my ascx
> (control):
>
> Page.RegisterClientScriptBlock("adder", "<script>function
> doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
> eval(document.all.TextBox2.value)}</script>");
> It doesn't work giving me all kind of problems...
> I suspect the problem is with <> charachters.
> How do I go around this problem?
> Also, placing this line in code (I use WebMatrix) will mess up all HTML
> code??
> Thanks!
I solved problem...

Actually the problem was in "</script>"

Changed to "<" + "/" + "script>" and it works fine now.

Thanks!

"Cliff Harris" <hersh@.myrealbox.com> wrote in message
news:OkD03L8oDHA.644@.TK2MSFTNGP11.phx.gbl...
> If that is the exact line from your code, then it just has to do with how
> your formed your string. You cannot insert a line break in a string in
C#.
> It should work if you change your code to read:
> Page.RegisterClientScriptBlock("adder", "<script>function " +
> "doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value)
+
> " +
> "eval(document.all.TextBox2.value)}</script>");
> or, for more readability, I always for my javascript in a temp variable
> first. Just kinda hard to read otherwise
> string script = "<script>function " +
> "doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value)
+
> " +
> "eval(document.all.TextBox2.value)}</script>"
> Page.RegisterClientScriptBlock("adder", script);
> either way, both of those should work for you.
> -Cliff
>
> "Ivan Demkovitch" <i@.a.b> wrote in message
> news:OfydJF8oDHA.976@.tk2msftngp13.phx.gbl...
> > Hi!
> > I'm trying to add script to the page and place following code in my ascx
> > (control):
> > Page.RegisterClientScriptBlock("adder", "<script>function
> > doadd(){document.all.TextBox3.value=eval(document. all.TextBox1.value) +
> > eval(document.all.TextBox2.value)}</script>");
> > It doesn't work giving me all kind of problems...
> > I suspect the problem is with <> charachters.
> > How do I go around this problem?
> > Also, placing this line in code (I use WebMatrix) will mess up all HTML
> > code??
> > Thanks!

Newline with HTMLEncode in Div and Label

Hi

I have a table column that has multiple lines (\r\n) and html tags in it. I
want to display it in a div and label that html tags can be seen and
newlines should work.
If i use div.innerHTML newlines are lost and html tags doesn't show.
If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks works
but html tags doesn't show.
If i use div.innerText again newlines and html tags are lost.

What can i do?

ThanksVersus,
The bottom line is that "\r\n" means nothing in HTML - you have to change it
to "<br/>" -- which means you need to pre-process your string with
..Replace("\r\n", "<br/>");

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
"versus" wrote:

Quote:

Originally Posted by

Hi
>
I have a table column that has multiple lines (\r\n) and html tags in it. I
want to display it in a div and label that html tags can be seen and
newlines should work.
If i use div.innerHTML newlines are lost and html tags doesn't show.
If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks works
but html tags doesn't show.
If i use div.innerText again newlines and html tags are lost.
>
What can i do?
>
Thanks
>
>
>


Thanks for answering. Replace(Environment.NewLine,"<br>") already works for
that problem. But i cannot see html tags as regular text. I want them to be
displayed not parsed with htmlparser.

Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines and
html tags to be displayed at the same time.

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yohohhoandabottleofrum.comwrote
in message news:4CA1F3DF-BB2B-479B-8025-69154C4984C5@.microsoft.com...

Quote:

Originally Posted by

Versus,
The bottom line is that "\r\n" means nothing in HTML - you have to change
it
to "<br/>" -- which means you need to pre-process your string with
.Replace("\r\n", "<br/>");
>
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com
>
>
>
"versus" wrote:
>

Quote:

Originally Posted by

>Hi
>>
>I have a table column that has multiple lines (\r\n) and html tags in it.
>I
>want to display it in a div and label that html tags can be seen and
>newlines should work.
>If i use div.innerHTML newlines are lost and html tags doesn't show.
>If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks
>works
>but html tags doesn't show.
>If i use div.innerText again newlines and html tags are lost.
>>
>What can i do?
>>
>Thanks
>>
>>
>>


"versus" <tencere@.dibin.karawrote in message
news:ee99xTJGIHA.4808@.TK2MSFTNGP05.phx.gbl...

Quote:

Originally Posted by

Thanks for answering. Replace(Environment.NewLine,"<br>") already works
for that problem. But i cannot see html tags as regular text. I want them
to be displayed not parsed with htmlparser.
>
Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines
and html tags to be displayed at the same time.
>
"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yohohhoandabottleofrum.com>
wrote in message
news:4CA1F3DF-BB2B-479B-8025-69154C4984C5@.microsoft.com...

Quote:

Originally Posted by

>Versus,
>The bottom line is that "\r\n" means nothing in HTML - you have to change
>it
>to "<br/>" -- which means you need to pre-process your string with
>.Replace("\r\n", "<br/>");
>>
>-- Peter
>Recursion: see Recursion
>site: http://www.eggheadcafe.com
>unBlog: http://petesbloggerama.blogspot.com
>BlogMetaFinder: http://www.blogmetafinder.com
>>
>>
>>
>"versus" wrote:
>>

Quote:

Originally Posted by

>>Hi
>>>
>>I have a table column that has multiple lines (\r\n) and html tags in
>>it. I
>>want to display it in a div and label that html tags can be seen and
>>newlines should work.
>>If i use div.innerHTML newlines are lost and html tags doesn't show.
>>If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks
>>works
>>but html tags doesn't show.
>>If i use div.innerText again newlines and html tags are lost.
>>>
>>What can i do?
>>>
>>Thanks
>>>
>>>
>>>


>
>


I think if you use the <pretag to wrap your code it will honor the CRLF
and show the tags as if they are text within the <pre></pretags.

Hope this helps
LS
I think if you use the <pretag to wrap your code it will honor the CRLF

Quote:

Originally Posted by

and show the tags as if they are text within the <pre></pretags.
>
Hope this helps
LS


Thanks but his solution removes css classes and when i use checkbox with
label, label click doesn't work.
On Sat, 27 Oct 2007 04:55:00 -0700, Peter Bromberg [C# MVP]
<pbromberg@.yahoo.yohohhoandabottleofrum.comwrote:

Quote:

Originally Posted by

>Versus,
>The bottom line is that "\r\n" means nothing in HTML - you have to change it
>to "<br/>" -- which means you need to pre-process your string with
>.Replace("\r\n", "<br/>");
>
>-- Peter
>Recursion: see Recursion
>site: http://www.eggheadcafe.com
>unBlog: http://petesbloggerama.blogspot.com
>BlogMetaFinder: http://www.blogmetafinder.com


Actually, newlines may make a lot of sense when you want your HTML to
be easily understood if you do a view source on the html page ...

--
http://bytes.thinkersroom.com
On 27 okt, 14:54, "Lloyd Sheen" <a...@.b.cwrote:

Quote:

Originally Posted by

"versus" <tenc...@.dibin.karawrote in message
>
news:ee99xTJGIHA.4808@.TK2MSFTNGP05.phx.gbl...
>

Quote:

Originally Posted by

Thanks for answering. Replace(Environment.NewLine,"<br>") already works
for that problem. But i cannot see html tags as regular text. I want them
to be displayed not parsed with htmlparser.


>

Quote:

Originally Posted by

Let me explain again. I have an sql db table with columns that has both
environment.newline(\r\n) and html tags. I want newlines to break lines
and html tags to be displayed at the same time.


>

Quote:

Originally Posted by

"Peter Bromberg [C# MVP]" <pbromb...@.yahoo.yohohhoandabottleofrum.com>
wrote in message
news:4CA1F3DF-BB2B-479B-8025-69154C4984C5@.microsoft.com...

Quote:

Originally Posted by

Versus,
The bottom line is that "\r\n" means nothing in HTML - you have to change
it
to "<br/>" -- which means you need to pre-process your string with
.Replace("\r\n", "<br/>");


>

Quote:

Originally Posted by

Quote:

Originally Posted by

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com


>

Quote:

Originally Posted by

Quote:

Originally Posted by

"versus" wrote:


>

Quote:

Originally Posted by

Quote:

Originally Posted by

>Hi


>

Quote:

Originally Posted by

Quote:

Originally Posted by

>I have a table column that has multiple lines (\r\n) and html tags in
>it. I
>want to display it in a div and label that html tags can be seen and
>newlines should work.
>If i use div.innerHTML newlines are lost and html tags doesn't show.
>If i use div.innerHTML with replace(Environment.NewLine,"<br>") breaks
>works
>but html tags doesn't show.
>If i use div.innerText again newlines and html tags are lost.


>

Quote:

Originally Posted by

Quote:

Originally Posted by

>What can i do?


>

Quote:

Originally Posted by

Quote:

Originally Posted by

>Thanks


>
I think if you use the <pretag to wrap your code it will honor the CRLF
and show the tags as if they are text within the <pre></pretags.
>
Hope this helps
LS


That's correct but the problem lies elsewhere.
If you update a <pretag with innerHTML, Internet Explorer will
remove the \n's before it's in the <pretag.