Showing posts with label newby. Show all posts
Showing posts with label newby. Show all posts

Thursday, March 22, 2012

newby needs no record found help

ok I'm new to ASP but I have everything working great I have a form in which client can look up status i want to be able to redirect to a no record found page when a wrong id number is entered here is website http://www.cargogroupllc.com/cargotracking.asp example of good record enter 12321 example of bad record 33333333 please help this is last thing I need to accomplishShow the code of the page, then I can help you!
Edited by SomeNewKid. Please post code between<code> and</code> tags.



ASP protion of page

<%
strSearch = Request.Form("search")

If strSearch <> "" Then
Dim strConnect, SQL
Dim RS
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("securefiles/ITtracking.mdb") & ";"

SQL = "SELECT * FROM ITTable WHERE INSTR(ITTable.ITNumber,'" & strSearch & "')"

Set RS = Server.CreateObject("Adodb.Recordset") 'Used for pulling main categories from DB
RS.Open SQL,strConnect

'If Len(strSearch) > 1 AND LCase(strSearch) = LCase(RS("Name")) Then
Response.Write RS("ITNumber") & "<BR><BR>"
Response.Write RS("DateArrived") & "<BR><BR>"
Response.Write RS("RefNumber") & "<BR><BR>"
Response.Write RS("Quantity") & "<BR><BR>"
Response.Write RS("PUDate") & "<BR><BR>"
Response.Write RS("PUNumber") & "<BR><BR>"
Response.Write RS("OriginalIT") & "<BR><BR>"
Response.Write RS("ValidatedIT") & "<BR><BR>"
Response.Write RS("CustomsRelease") & "<BR><BR>"
Response.Write RS("ShippingTally") & "<BR><BR>"
Response.Write RS("NVOCCRelease") & "<BR><BR>"
Response.Write RS("PaperlessIT") & "<BR><BR>"
'End If

'If Len(strSearch) <= 0 Then
'Response.Write "Sorry no record & "<BR>"
'Response.Write RS(sorry no record) & "<BR><BR>"

'End If

RS.MoveNext

RS.Close

End If

%>

Newby level question: Radio Buttons

Hello,

I have a web page that gets the user to select items from a list of options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the possibility of multiple selections. However, one item is "None of the above" and I have placed some logic (autopostback, etc.) that will remove all previous selections if "None of the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with AutoPostback enabled (and someone selects one of these Radio Buttons) the web browser refreshes the screen and shows the top of the page. What can I do such that the screen refreshes and displays the bottom portion with the Radio Buttons? Or is there a way to do what I want to do without using AutoPostback?

TIA...Ferret Face,

You could try out setting the page's Smart Navigation property to true. Smart navigation keeps the screen position during post backs. But it doesn't work for any browser (that I know of) except IE and it can cause flaky behaviour.

Because of this I created a javascript that will automatically scroll a page to whatever control you specify as a reusable object. Actually the javascript object contains many useful scripts.

You can download the Javascript component I built for free with full source code as a VS2003 project from my website, www.aboutfortunate.com. Also download the .chm help file. It gives help for every control I've created all of which are downloadable from my site for free with full source.

To get the javascript component click the "Code Library" link at the top of my page and then click the "Javacript" button on the left.

You'll want to use the "ScrollToElement" method of the component.

If you have any questions about the component or use thereof feel free to email me.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Ferret Face" <ferretface@.msn.com> wrote in message news:LvidnWJEMaeBDr3eRVn-tw@.giganews.com...
Hello,

I have a web page that gets the user to select items from a list of options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the possibility of multiple selections. However, one item is "None of the above" and I have placed some logic (autopostback, etc.) that will remove all previous selections if "None of the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with AutoPostback enabled (and someone selects one of these Radio Buttons) the web browser refreshes the screen and shows the top of the page. What can I do such that the screen refreshes and displays the bottom portion with the Radio Buttons? Or is there a way to do what I want to do without using AutoPostback?

TIA...
One solution is to enable SmartNavigation, although there are a lot of
reasons not to do so
(http://weblogs.asp.net/ksamaschke/a...04/27/6085.aspx,
http://weblogs.asp.net/dreilly/arch.../14/229424.aspx

Alternatively, you might want to take a look at the free (but no source
code) Smart Scroller:
http://www.strengthtechnologies.com/scroll/

Finally, you can likely achieve all that you want in JavaScript if that's
acceptable. Here's a quick example, might not work but should give you an
idea...

<div id="choices">
<input type="Radio" name="1" value="choice1">
<input type="Radio" name="2" value="choice2">
<input type="Radio" name="3" value="choice3">
<input type="Radio" name="4" value="choice4">
<input type="Radio" name="5" value="none" onClick="Clicked('choices',
this);">
</div
<script language="JavaScript">
function Clicked(containerName, source)
{
var container = document.getElementById(containerName);
if (!container){
//something went wrong
return;
}
var inputs = container.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; ++i)
{
var input = inputs[i];
//if we have a radiobutton (we don't want to disable a textbox in here
too, or do we?) AND we aren't on the "none" button
if (input.type.toUpperCase() == "RADIO" && input.value != "none")
{
input.disabled = source.checked; //if our non button is checked, the
input is disabled, if it isn't checked, it's enabled.
}
}
}
</script>
--
MY ASP.Net tutorials
http://www.openmymind.net/

"Ferret Face" <ferretface@.msn.com> wrote in message
news:LvidnWJEMaeBDr3eRVn-tw@.giganews.com...
Hello,

I have a web page that gets the user to select items from a list of
options. This list is a set of independant Radio Buttons. I did not use a
Radio Button List because I wanted the possibility of multiple selections.
However, one item is "None of the above" and I have placed some logic
(autopostback, etc.) that will remove all previous selections if "None of
the above" is chosen. My problem is this:

This list of Radio Buttons is at the bottom of the web page and with
AutoPostback enabled (and someone selects one of these Radio Buttons) the
web browser refreshes the screen and shows the top of the page. What can I
do such that the screen refreshes and displays the bottom portion with the
Radio Buttons? Or is there a way to do what I want to do without using
AutoPostback?

TIA...
Hey! Who you callin' Ferret Face?!
... Wait, that's my name.

That JavaScript did the trick. I had to brush-up on JavaScript a bit to
do it. I ended up changing the line

if (input.type.toUpperCase() == "RADIO" && input.value != source.value)

to make it work.

Thanks!

"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23bJ5xBLtFHA.4080@.TK2MSFTNGP12.phx.gbl...
> One solution is to enable SmartNavigation, although there are a lot of
> reasons not to do so
> (http://weblogs.asp.net/ksamaschke/a...04/27/6085.aspx,
> http://weblogs.asp.net/dreilly/arch.../14/229424.aspx
> Alternatively, you might want to take a look at the free (but no source
> code) Smart Scroller:
> http://www.strengthtechnologies.com/scroll/
> Finally, you can likely achieve all that you want in JavaScript if that's
> acceptable. Here's a quick example, might not work but should give you an
> idea...
> <div id="choices">
> <input type="Radio" name="1" value="choice1">
> <input type="Radio" name="2" value="choice2">
> <input type="Radio" name="3" value="choice3">
> <input type="Radio" name="4" value="choice4">
> <input type="Radio" name="5" value="none" onClick="Clicked('choices',
> this);">
> </div>
> <script language="JavaScript">
> function Clicked(containerName, source)
> {
> var container = document.getElementById(containerName);
> if (!container){
> //something went wrong
> return;
> }
> var inputs = container.getElementsByTagName("INPUT");
> for (var i = 0; i < inputs.length; ++i)
> {
> var input = inputs[i];
> //if we have a radiobutton (we don't want to disable a textbox in here
> too, or do we?) AND we aren't on the "none" button
> if (input.type.toUpperCase() == "RADIO" && input.value != "none")
> {
> input.disabled = source.checked; //if our non button is checked, the
> input is disabled, if it isn't checked, it's enabled.
> }
> }
> }
> </script>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
> "Ferret Face" <ferretface@.msn.com> wrote in message
> news:LvidnWJEMaeBDr3eRVn-tw@.giganews.com...
> Hello,
> I have a web page that gets the user to select items from a list of
> options. This list is a set of independant Radio Buttons. I did not use
a
> Radio Button List because I wanted the possibility of multiple selections.
> However, one item is "None of the above" and I have placed some logic
> (autopostback, etc.) that will remove all previous selections if "None of
> the above" is chosen. My problem is this:
> This list of Radio Buttons is at the bottom of the web page and with
> AutoPostback enabled (and someone selects one of these Radio Buttons) the
> web browser refreshes the screen and shows the top of the page. What can
I
> do such that the screen refreshes and displays the bottom portion with the
> Radio Buttons? Or is there a way to do what I want to do without using
> AutoPostback?
> TIA...

Newby level question: Radio Buttons

Hello,
I have a web page that gets the user to select items from a list of options.
This list is a set of independant Radio Buttons. I did not use a Radio Bu
tton List because I wanted the possibility of multiple selections. However,
one item is "None of the above" and I have placed some logic (autopostback,
etc.) that will remove all previous selections if "None of the above" is ch
osen. My problem is this:
This list of Radio Buttons is at the bottom of the web page and with AutoPos
tback enabled (and someone selects one of these Radio Buttons) the web brows
er refreshes the screen and shows the top of the page. What can I do such t
hat the screen refreshes and displays the bottom portion with the Radio Butt
ons? Or is there a way to do what I want to do without using AutoPostback?
TIA...Ferret Face,
You could try out setting the page's Smart Navigation property to true. Smar
t navigation keeps the screen position during post backs. But it doesn't wor
k for any browser (that I know of) except IE and it can cause flaky behaviou
r.
Because of this I created a javascript that will automatically scroll a page
to whatever control you specify as a reusable object. Actually the javascri
pt object contains many useful scripts.
You can download the Javascript component I built for free with full source code as a V
S2003 project from my website, www.aboutfortunate.com. Also download the .ch
m help file. It gives help for every control I've created all of which are d
ownloadable from my site for free with full source.
To get the javascript component click the "Code Library" link at the top of
my page and then click the "Javacript" button on the left.
You'll want to use the "ScrollToElement" method of the component.
If you have any questions about the component or use thereof feel free to em
ail me.
--
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"Ferret Face" <ferretface@.msn.com> wrote in message news:LvidnWJEMaeBDr3eRVn
-tw@.giganews.com...
Hello,
I have a web page that gets the user to select items from a list of options.
This list is a set of independant Radio Buttons. I did not use a Radio Bu
tton List because I wanted the possibility of multiple selections. However,
one item is "None of the above" and I have placed some logic (autopostback,
etc.) that will remove all previous selections if "None of the above" is ch
osen. My problem is this:
This list of Radio Buttons is at the bottom of the web page and with AutoPos
tback enabled (and someone selects one of these Radio Buttons) the web brows
er refreshes the screen and shows the top of the page. What can I do such t
hat the screen refreshes and displays the bottom portion with the Radio Butt
ons? Or is there a way to do what I want to do without using AutoPostback?
TIA...
One solution is to enable SmartNavigation, although there are a lot of
reasons not to do so
(http://weblogs.asp.net/ksamaschke/a...4/27/6085.aspx,
http://weblogs.asp.net/dreilly/arch.../14/229424.aspx
Alternatively, you might want to take a look at the free (but no source
code) Smart Scroller:
http://www.strengthtechnologies.com/scroll/
Finally, you can likely achieve all that you want in JavaScript if that's
acceptable. Here's a quick example, might not work but should give you an
idea...
<div id="choices">
<input type="Radio" name="1" value="choice1">
<input type="Radio" name="2" value="choice2">
<input type="Radio" name="3" value="choice3">
<input type="Radio" name="4" value="choice4">
<input type="Radio" name="5" value="none" onClick="Clicked('choices',
this);">
</div>
<script language="JavaScript">
function Clicked(containerName, source)
{
var container = document.getElementById(containerName);
if (!container){
//something went wrong
return;
}
var inputs = container.getElementsByTagName("INPUT");
for (var i = 0; i < inputs.length; ++i)
{
var input = inputs[i];
//if we have a radiobutton (we don't want to disable a textbox in here
too, or do we?) AND we aren't on the "none" button
if (input.type.toUpperCase() == "RADIO" && input.value != "none")
{
input.disabled = source.checked; //if our non button is checked, the
input is disabled, if it isn't checked, it's enabled.
}
}
}
</script>
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Ferret Face" <ferretface@.msn.com> wrote in message
news:LvidnWJEMaeBDr3eRVn-tw@.giganews.com...
Hello,
I have a web page that gets the user to select items from a list of
options. This list is a set of independant Radio Buttons. I did not use a
Radio Button List because I wanted the possibility of multiple selections.
However, one item is "None of the above" and I have placed some logic
(autopostback, etc.) that will remove all previous selections if "None of
the above" is chosen. My problem is this:
This list of Radio Buttons is at the bottom of the web page and with
AutoPostback enabled (and someone selects one of these Radio Buttons) the
web browser refreshes the screen and shows the top of the page. What can I
do such that the screen refreshes and displays the bottom portion with the
Radio Buttons? Or is there a way to do what I want to do without using
AutoPostback?
TIA...
Hey! Who you callin' Ferret Face?!
... Wait, that's my name.
That JavaScript did the trick. I had to brush-up on JavaScript a bit to
do it. I ended up changing the line
if (input.type.toUpperCase() == "RADIO" && input.value != source.value)
to make it work.
Thanks!
"Karl Seguin" <karl REMOVE @. REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:%23bJ5xBLtFHA.4080@.TK2MSFTNGP12.phx.gbl...
> One solution is to enable SmartNavigation, although there are a lot of
> reasons not to do so
> (http://weblogs.asp.net/ksamaschke/a...4/27/6085.aspx,
> http://weblogs.asp.net/dreilly/arch.../14/229424.aspx
> Alternatively, you might want to take a look at the free (but no source
> code) Smart Scroller:
> http://www.strengthtechnologies.com/scroll/
> Finally, you can likely achieve all that you want in JavaScript if that's
> acceptable. Here's a quick example, might not work but should give you an
> idea...
> <div id="choices">
> <input type="Radio" name="1" value="choice1">
> <input type="Radio" name="2" value="choice2">
> <input type="Radio" name="3" value="choice3">
> <input type="Radio" name="4" value="choice4">
> <input type="Radio" name="5" value="none" onClick="Clicked('choices',
> this);">
> </div>
> <script language="JavaScript">
> function Clicked(containerName, source)
> {
> var container = document.getElementById(containerName);
> if (!container){
> //something went wrong
> return;
> }
> var inputs = container.getElementsByTagName("INPUT");
> for (var i = 0; i < inputs.length; ++i)
> {
> var input = inputs[i];
> //if we have a radiobutton (we don't want to disable a textbox in here
> too, or do we?) AND we aren't on the "none" button
> if (input.type.toUpperCase() == "RADIO" && input.value != "none")
> {
> input.disabled = source.checked; //if our non button is checked, the
> input is disabled, if it isn't checked, it's enabled.
> }
> }
> }
> </script>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
> "Ferret Face" <ferretface@.msn.com> wrote in message
> news:LvidnWJEMaeBDr3eRVn-tw@.giganews.com...
> Hello,
> I have a web page that gets the user to select items from a list of
> options. This list is a set of independant Radio Buttons. I did not use
a
> Radio Button List because I wanted the possibility of multiple selections.
> However, one item is "None of the above" and I have placed some logic
> (autopostback, etc.) that will remove all previous selections if "None of
> the above" is chosen. My problem is this:
> This list of Radio Buttons is at the bottom of the web page and with
> AutoPostback enabled (and someone selects one of these Radio Buttons) the
> web browser refreshes the screen and shows the top of the page. What can
I
> do such that the screen refreshes and displays the bottom portion with the
> Radio Buttons? Or is there a way to do what I want to do without using
> AutoPostback?
> TIA...
>

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 Q about using Google Maps with ASP.Net 2.0

Ok, over the years I have read about doing web programing and I have
done some real basic stuff. Now I am digging into some real ASP.Net
2.0 and am totally lost some things.

I have a master page setup and that is working great. On my contact
page I would like to use Google Maps API Version 2 to show a map to my
location. Below is the first Google example.

I would like to add this to my aspx page that is using the master page.
I don't understand how to link to the google JS nor how exactly to
add the inline JS load() method to the .aspx page. Any suggestions?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script
src="http://maps.google.com/maps?file=api&v=2&key=abcdefg"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}

//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="; height: 300px"></div>
</body>
</htmlCopy everthing from the "<script" to the "/script>" and paste it into the
<head> portion of the HTML in your ASP.Net page (between the "<head>" and
"</head>" tags). And do yourself a favor and learn something about HTML. All
ASP.Net does is render HTML to a browser from the server (all that you need
to know about it right now, that is). If you don't understand HTML, and then
JavaScript, you will *never* understand ASP.Net. HTML is easy. It's just a
markup language Programming is hard. Start with the easy part.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

"Sam Carleton" <scarleton@.gmail.com> wrote in message
news:1150859005.233489.315340@.i40g2000cwc.googlegr oups.com...
> Ok, over the years I have read about doing web programing and I have
> done some real basic stuff. Now I am digging into some real ASP.Net
> 2.0 and am totally lost some things.
> I have a master page setup and that is working great. On my contact
> page I would like to use Google Maps API Version 2 to show a map to my
> location. Below is the first Google example.
> I would like to add this to my aspx page that is using the master page.
> I don't understand how to link to the google JS nor how exactly to
> add the inline JS load() method to the .aspx page. Any suggestions?
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html;
> charset=utf-8"/>
> <title>Google Maps JavaScript API Example</title>
> <script
> src="http://pics.10026.com/?src=http://maps.google.com/maps?file=api&v=2&key=abcdefg"
> type="text/javascript"></script>
> <script type="text/javascript">
> //<![CDATA[
> function load() {
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map"));
> map.setCenter(new GLatLng(37.4419, -122.1419), 13);
> }
> }
> //]]>
> </script>
> </head>
> <body onload="load()" onunload="GUnload()">
> <div id="map" style="; height: 300px"></div>
> </body>
> </html
Try using Google Maps control from this site:
http://www.reimers.dk/

Sam Carleton wrote:
> Ok, over the years I have read about doing web programing and I have
> done some real basic stuff. Now I am digging into some real ASP.Net
> 2.0 and am totally lost some things.
> I have a master page setup and that is working great. On my contact
> page I would like to use Google Maps API Version 2 to show a map to my
> location. Below is the first Google example.
> I would like to add this to my aspx page that is using the master page.
> I don't understand how to link to the google JS nor how exactly to
> add the inline JS load() method to the .aspx page. Any suggestions?
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html;
> charset=utf-8"/>
> <title>Google Maps JavaScript API Example</title>
> <script
> src="http://pics.10026.com/?src=http://maps.google.com/maps?file=api&v=2&key=abcdefg"
> type="text/javascript"></script>
> <script type="text/javascript">
> //<![CDATA[
> function load() {
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map"));
> map.setCenter(new GLatLng(37.4419, -122.1419), 13);
> }
> }
> //]]>
> </script>
> </head>
> <body onload="load()" onunload="GUnload()">
> <div id="map" style="; height: 300px"></div>
> </body>
> </html
Kevin Spencer wrote:
> Copy everthing from the "<script" to the "/script>" and paste it into the
> <head> portion of the HTML in your ASP.Net page (between the "<head>" and
> "</head>" tags). And do yourself a favor and learn something about HTML. All
> ASP.Net does is render HTML to a browser from the server (all that you need
> to know about it right now, that is). If you don't understand HTML, and then
> JavaScript, you will *never* understand ASP.Net. HTML is easy. It's just a
> markup language Programming is hard. Start with the easy part.

Kevin,

First off, I am a professionally software developer, all my experence
is in Windows Development (C/C++/C#). I do know HTML, on a scale of 1
to 5, I would guess it is around a 3, maybe a 4. My JS skill is around
a 3. But when it comes to ASP.Net 2.0, I know it about a 1 out of 5.
That is where I am a newbe, ASP.Net 2.0.

I looked at my contact.aspx page, *which is using a master page*, and
there is not <head></head>, only the two different <asp:Contect> tags
to fill in the Content section from the Master page. I get the
impression that there is away to add the inline JS, the link to the JS
on google's web site, and the onload/onunload to the contact.aspx page,
but that it is none standard. (by the way, this is what has always
thrown me off about web development frameworks, each one does it's own
unquie thing to implement basic HTML).

Maybe there is simply a good section in the MSDN I should have alook at
that will explain this type of thing, when using master pages.

Sam
Jacob wrote:
> Try using Google Maps control from this site:
> http://www.reimers.dk/

That is great, but... I would like to *UNDERSTAND* how to do it
myself, the source code to the control at that link is not available:(

Sam
Google recommends placing the script in the head and then running it
from the body's onload event. This is done to overcome what is
generally known as the "IE Operation Aborted problem", meaning that IE
won't allow you to change the contents of a tag before it's finished
loading.

In master pages you could conceivably add the script to the head
programatically, but another solution would be to add the script
anywhere on the page and make use of the defer attribute. There is no
law of nature saying that the script has to be placed in the head.

Sam Carleton wrote:
> Kevin Spencer wrote:
> > Copy everthing from the "<script" to the "/script>" and paste it into the
> > <head> portion of the HTML in your ASP.Net page (between the "<head>" and
> > "</head>" tags). And do yourself a favor and learn something about HTML. All
> > ASP.Net does is render HTML to a browser from the server (all that you need
> > to know about it right now, that is). If you don't understand HTML, and then
> > JavaScript, you will *never* understand ASP.Net. HTML is easy. It's just a
> > markup language Programming is hard. Start with the easy part.
> Kevin,
> First off, I am a professionally software developer, all my experence
> is in Windows Development (C/C++/C#). I do know HTML, on a scale of 1
> to 5, I would guess it is around a 3, maybe a 4. My JS skill is around
> a 3. But when it comes to ASP.Net 2.0, I know it about a 1 out of 5.
> That is where I am a newbe, ASP.Net 2.0.
> I looked at my contact.aspx page, *which is using a master page*, and
> there is not <head></head>, only the two different <asp:Contect> tags
> to fill in the Content section from the Master page. I get the
> impression that there is away to add the inline JS, the link to the JS
> on google's web site, and the onload/onunload to the contact.aspx page,
> but that it is none standard. (by the way, this is what has always
> thrown me off about web development frameworks, each one does it's own
> unquie thing to implement basic HTML).
> Maybe there is simply a good section in the MSDN I should have alook at
> that will explain this type of thing, when using master pages.
> Sam
In our master page, we put a contentplaceholder tag between the HTML head
tags, then we stuff the scripts in there. Also, if you build a server
control, you can set up the scripts as a resource and override the OnLoad
like this:

protected override void OnLoad(EventArgs e)
{
Type t = this.GetType();
String js = "MyNameSpace.WebControls.MyJavaScript.js";
String url = Page.ClientScript.GetWebResourceUrl(t, js);
Page.ClientScript.RegisterClientScriptInclude(t, js, url);

base.OnLoad(e);
}

The nice thing about this is it packages it in your dll. Hope this helps.

Diane

"Sam Carleton" wrote:

Quote:

Originally Posted by

>
Jacob wrote:

Quote:

Originally Posted by

Try using Google Maps control from this site:
http://www.reimers.dk/


That is great, but... I would like to *UNDERSTAND* how to do it
myself, the source code to the control at that link is not available:(
Sam
>


newby Q about using Google Maps with ASP.Net 2.0

Ok, over the years I have read about doing web programing and I have
done some real basic stuff. Now I am digging into some real ASP.Net
2.0 and am totally lost some things.
I have a master page setup and that is working great. On my contact
page I would like to use Google Maps API Version 2 to show a map to my
location. Below is the first Google example.
I would like to add this to my aspx page that is using the master page.
I don't understand how to link to the google JS nor how exactly to
add the inline JS load() method to the .aspx page. Any suggestions?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;
charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script
src="http://maps.google.com/maps?file=api&v=2&key=abcdefg"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
</html>Copy everthing from the "<script" to the "/script>" and paste it into the
<head> portion of the HTML in your ASP.Net page (between the "<head>" and
"</head>" tags). And do yourself a favor and learn something about HTML. All
ASP.Net does is render HTML to a browser from the server (all that you need
to know about it right now, that is). If you don't understand HTML, and then
JavaScript, you will *never* understand ASP.Net. HTML is easy. It's just a
markup language Programming is hard. Start with the easy part.
HTH,
Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist
I recycle.
I send everything back to the planet it came from.
"Sam Carleton" <scarleton@.gmail.com> wrote in message
news:1150859005.233489.315340@.i40g2000cwc.googlegroups.com...
> Ok, over the years I have read about doing web programing and I have
> done some real basic stuff. Now I am digging into some real ASP.Net
> 2.0 and am totally lost some things.
> I have a master page setup and that is working great. On my contact
> page I would like to use Google Maps API Version 2 to show a map to my
> location. Below is the first Google example.
> I would like to add this to my aspx page that is using the master page.
> I don't understand how to link to the google JS nor how exactly to
> add the inline JS load() method to the .aspx page. Any suggestions?
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html;
> charset=utf-8"/>
> <title>Google Maps JavaScript API Example</title>
> <script
> src="http://pics.10026.com/?src=http://maps.google.com/maps?file=api&v=2&key=abcdefg"
> type="text/javascript"></script>
> <script type="text/javascript">
> //<![CDATA[
> function load() {
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map"));
> map.setCenter(new GLatLng(37.4419, -122.1419), 13);
> }
> }
> //]]>
> </script>
> </head>
> <body onload="load()" onunload="GUnload()">
> <div id="map" style="width: 500px; height: 300px"></div>
> </body>
> </html>
>
Try using Google Maps control from this site:
http://www.reimers.dk/
Sam Carleton wrote:
> Ok, over the years I have read about doing web programing and I have
> done some real basic stuff. Now I am digging into some real ASP.Net
> 2.0 and am totally lost some things.
> I have a master page setup and that is working great. On my contact
> page I would like to use Google Maps API Version 2 to show a map to my
> location. Below is the first Google example.
> I would like to add this to my aspx page that is using the master page.
> I don't understand how to link to the google JS nor how exactly to
> add the inline JS load() method to the .aspx page. Any suggestions?
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="content-type" content="text/html;
> charset=utf-8"/>
> <title>Google Maps JavaScript API Example</title>
> <script
> src="http://pics.10026.com/?src=http://maps.google.com/maps?file=api&v=2&key=abcdefg"
> type="text/javascript"></script>
> <script type="text/javascript">
> //<![CDATA[
> function load() {
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map"));
> map.setCenter(new GLatLng(37.4419, -122.1419), 13);
> }
> }
> //]]>
> </script>
> </head>
> <body onload="load()" onunload="GUnload()">
> <div id="map" style="width: 500px; height: 300px"></div>
> </body>
> </html>
Kevin Spencer wrote:
> Copy everthing from the "<script" to the "/script>" and paste it into the
> <head> portion of the HTML in your ASP.Net page (between the "<head>" and
> "</head>" tags). And do yourself a favor and learn something about HTML. A
ll
> ASP.Net does is render HTML to a browser from the server (all that you nee
d
> to know about it right now, that is). If you don't understand HTML, and th
en
> JavaScript, you will *never* understand ASP.Net. HTML is easy. It's just a
> markup language Programming is hard. Start with the easy part.
Kevin,
First off, I am a professionally software developer, all my experence
is in Windows Development (C/C++/C#). I do know HTML, on a scale of 1
to 5, I would guess it is around a 3, maybe a 4. My JS skill is around
a 3. But when it comes to ASP.Net 2.0, I know it about a 1 out of 5.
That is where I am a newbe, ASP.Net 2.0.
I looked at my contact.aspx page, *which is using a master page*, and
there is not <head></head>, only the two different <asp:Contect> tags
to fill in the Content section from the Master page. I get the
impression that there is away to add the inline JS, the link to the JS
on google's web site, and the onload/onunload to the contact.aspx page,
but that it is none standard. (by the way, this is what has always
thrown me off about web development frameworks, each one does it's own
unquie thing to implement basic HTML).
Maybe there is simply a good section in the MSDN I should have alook at
that will explain this type of thing, when using master pages.
Sam
Jacob wrote:
> Try using Google Maps control from this site:
> http://www.reimers.dk/
That is great, but... I would like to *UNDERSTAND* how to do it
myself, the source code to the control at that link is not available:(
Sam
Google recommends placing the script in the head and then running it
from the body's onload event. This is done to overcome what is
generally known as the "IE Operation Aborted problem", meaning that IE
won't allow you to change the contents of a tag before it's finished
loading.
In master pages you could conceivably add the script to the head
programatically, but another solution would be to add the script
anywhere on the page and make use of the defer attribute. There is no
law of nature saying that the script has to be placed in the head.
Sam Carleton wrote:
> Kevin Spencer wrote:
> Kevin,
> First off, I am a professionally software developer, all my experence
> is in Windows Development (C/C++/C#). I do know HTML, on a scale of 1
> to 5, I would guess it is around a 3, maybe a 4. My JS skill is around
> a 3. But when it comes to ASP.Net 2.0, I know it about a 1 out of 5.
> That is where I am a newbe, ASP.Net 2.0.
> I looked at my contact.aspx page, *which is using a master page*, and
> there is not <head></head>, only the two different <asp:Contect> tags
> to fill in the Content section from the Master page. I get the
> impression that there is away to add the inline JS, the link to the JS
> on google's web site, and the onload/onunload to the contact.aspx page,
> but that it is none standard. (by the way, this is what has always
> thrown me off about web development frameworks, each one does it's own
> unquie thing to implement basic HTML).
> Maybe there is simply a good section in the MSDN I should have alook at
> that will explain this type of thing, when using master pages.
> Sam

Newby Question

I need to pass a value from a URL in an e-mail message that contains a ticket number that will be picked up as a variable in an ASPX page. Can anyone give me the syntax for this?

I need to know how to format it correctly on the URL in the e-mail, and assign that number to a variable in the ASPX page.

Thanks!
Chrishttp://www.example.com?ticketID=x823Y230


Dim strTicketID as string
strTickedID = request.querystring("ticketID")

Thanks - worked like a charm!

Newby Question

Hi All,

I would like to know how I would check of the third digit in a number is a 0 or not...

so i can say......if the third digit is 0 then do domething......

if xxxx(120456789) = 0 then do this....

rgs

TonyWell you can do this a number of ways. You could try this one.

Dim sNumbers as String = "124509"
Dim x as Int32

x = sNumbers.IndexOf("0")

If x = 2 Then
'0 is the third digit
End If

Of course, if the "string" of integers is of type Integer, then you'll need to convert it to a string first.
An interesting way (assuming your are looking RIGHT to LEFT):

Function GetDigit( ByVal lNumber As Long, ByVal intDigit As Integer ) As Integer

If intDigit < 1 Then
Return -1 ' invalid request
End If

' lNumber = 4324
' intDigit = 3

' lNumber /= 10^2 (100)
' lNumber = 43
' 43 Mod 10 = 3

lNumber /= Math.Pow(10, intDigit - 1)

Return CInt(lNumber Mod 10)

End Function

No Math way (assuming LEFT to RIGHT):
Function GetDigit( ByVal lNumber As Long, ByVal intDigit As Integer ) As Integer

If intDigit < 1 Then
Return -1 ' invalid request
End If

Dim strNumber As String = lNumber.ToString()

If strNumber.Length >= intDigit Then
Return CInt(Char.GetNumericValue(strNumber.Chars(intDigit - 1))) ' For RIGHT to LEFT: change "intDigit - 1" to "strNumber.Length - intDigit - 1"
Else
' invalid request
Return -1
End If

End Function


Frank, what if the number is "123400" ?

Then x = 4, and also 5 if you look further.
gents.,,.....

my number can and will look like these

900000001
980654021
900004321
984000321
980000321

will mid work

dim my var as integer = 900000001

if mid(myvar, 1,"1") = 9 then the above is true

if mid(myvar, 1,"0") = 0then the above is true

may need a long here...

many thanks...
Use my second function example and simply plug in the number:

If GetDigit(900000001, 1) = 9 Then
' The first digit is 9
End If

If GetDigit(900000001, 3) = 0 Then
' The third digit is 0
End If

Obviously, you can replace the actual number with a variable.
pickyh3d:

But wasn't he just looking for "0" in the third index? So wouldn't IndexOf bring back the index of the first occurence? So if the string is what you provided: "123400", then the index it would return would be 4. Therefore we know that 0 IS NOT in the third position.

That's where I was going with my example, but maybe I misunderstood...?
Well, I was leaning towards more of the problematic approach and I showed the numbers backwards (because initially I was thinking read from right-to-left).

Imagine this number then:

103000

IndexOf('0') would return 1, which would require another search.
how about...

"103000".IndexOf("0",2)

lets not forget that IndexOf has an overload that takes a starting position
Gotcha! I didn't give that one enough thought, and that would definitely be a pitfall.
mbanavige:

Good call, that looks like a solid solution. Now you're just looking at the third position, which makes more sense.
I have to admit, i'm partial to the substring solution.

although we can get IndexOf to start at the 3rd position, it will happily search till it hits the end of the string which is still more work that is required for the solution. Also, it will throw an error if we try to start it past the end of the string so additional error handling is required.
Ya, I was thinking about the [second param] starting position the whole time, but well, I think we are in agreement at this point.

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 RE transfering data between pages.

I am hoping that this is a simple problem. I have a page that has a button the code for that button is as follows.

protectedvoid btnServerSearch_Click(object sender,EventArgs e)

{

string scriptStr ="<script type=text/javascript>window.open('FrmLoanSelect.aspx',null,'height=400,width=650');</script>";

ClientScript.RegisterClientScriptBlock(this.GetType(),"Pop", scriptStr);

txLoanNumber.Text = (string)Session["DaData"];

}

When I click the button the new page displays beautifully in a window, in the dimensions that I requests. The code that is setting the session variable "DaData" is in the page being displayed as follows.

protectedvoid GridView1_SelectedIndexChanged(object sender,EventArgs e)

{

Session["DaData"] = GridView1.Rows[GridView1.SelectedIndex].Cells[1].Text;

}

The problem appears to be that the main form is not waiting on the form it just displayed and therefore the session variable doesnt exist yet. Is there some way to make the main form wait for the exit of the popup form ? Or am I going to have to find some other way of passing the data from the popup form ?

Any input that anyone has is mughty appreciated!!

Bump for the non-weekend crowd.

Hi,

The solution lies in using Modal Pop ups.

I have put together a small example for you.

In the calling (main page) use a client script to open up a modal window.

Main Page Code Behind

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes.Add("onClick", "ShowPop();");

}
protected void Button1_Click(object sender, EventArgs e)
{
string x= (string)Session["X"];

}
}

javascript:

function ShowPop()
{
var win = window.showModalDialog('PopUpWindow.aspx', '', 'dialogHeight: 200px; dialogWidth: 300px; help: No; resizable: No; status: No;');
}

Called Page, Pop Up. Code Behind

ublic partial class PopUpWindow : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
Session["X"] = TextBox1.Text;

string scriptStr = "<script type=text/javascript>window.close();</script>";

ClientScript.RegisterClientScriptBlock(this.GetType(), "Pop", scriptStr);
}
}

This way, ur main page calls a popup, the pop up sets a value in session and closes itself( all this while the main page is still active)

The main page button on click gets invoked and it can access the value set in session

lemme know if this helps.

Deepak.


Thank you very much for the response!!

I think that I am 90% of the way there. The better news is that I managed to learn a LOT from your post :) I finally grasped that you can add client side event handlers to a server control using the attribute.add method.

That problem that I am encountering now is, I think, insurmountable, at least it seems that way to me. I am displaying a grid in my popup window, and when ever I select an entry in the grid, or try to select a different page on the grid its doing a postback, and that is giving me an error. The error details ( as seen in the Internet Explorer Error box ) Line: 1 Char: 1 Error: Object Expected Code: 0 URL: javascript:__doPostBack('GridView1','Page$6'). This specific error message was displayed when I tried to swap to page 6 of the gridview. When I try to select a specific value in the grid the message changes in the URL: portion to URL: javascript:__doPostBack('GridView1','Select$7').

This though makes sense to me that I am getting these errors, as I am trying to do a postback on a form that I specifically invoked as Modal. If I am wrong in this and Ive missed somthing I would love to hear it!

Once again thank you greatly for the help!!

Vince Campanile


A few things to look for:

1) Make sure you do not have any javascript syntax errors

2)If the script is in diff file, make sure you have included the src in ur script declaration

If you can paste ur code template, I can try to see the issue.

From a first glance looks like its lookin for a function and its not finding it...

HTH

Deepak.


Not sure what your refering to when you ask about the script. Do you mean the Script thats actually calling the modalDialog ?

Here is the entirety of the window that I am creating, with the exception that I have redacted out the database information

<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="FrmLoanSelect.aspx.cs" Inherits="BrokeredLoans.FrmLoanSelect" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Select Loan</title></head><body> <form id="form1" runat="server"> <div> <asp:GridView ID="gvLoanSelections" runat="server" AutoGenerateColumns="False" DataKeyNames="loanMasterID" DataSourceID="dsLoanSelect" Height="138px" Width="638px" AllowPaging="True" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" OnSelectedIndexChanged="gvLoanSelections_SelectedIndexChanged"> <Columns> <asp:CommandField ShowSelectButton="True" /> <asp:BoundField DataField="loanNumber" HeaderText="Loan Number" SortExpression="loanNumber" /> <asp:BoundField DataField="borrowerFirstName" HeaderText="First Name" SortExpression="borrowerFirstName" /> <asp:BoundField DataField="borrowerLastName" HeaderText="Last Name" SortExpression="borrowerLastName" /> <asp:BoundField DataField="fundedDate" HeaderText="Funded Date" SortExpression="fundedDate" /> </Columns> <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" /> <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" /> <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" /> <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" /> </asp:GridView> </div> </form></body></html>

Here is the code behind page that is for that web page.

namespace BrokeredLoans{public partialclass FrmLoanSelect : System.Web.UI.Page {protected void gvLoanSelections_SelectedIndexChanged(object sender, EventArgs e) { Session["DaData"] = gvLoanSelections.Rows[gvLoanSelections.SelectedIndex].Cells[1].Text;string scriptStr ="<script type=text/javascript>window.close();</script>"; ClientScript.RegisterClientScriptBlock(this.GetType(),"Pop", scriptStr); } }}
 
The code that is calling the popup is as follows.
 
<script type="text/jscript"> function ShowPopup() { var win = window.showModalDialog('FrmLoanSelect.aspx','','dialogHeight=400,dialogWidth=725,resizable: No;status: No'); }</script>
 
Thank you so much for taking the time out to help this newby along! :)

Another little tidbit of information...

I added another button to just plain show the search screen and when I make a selection there, or change the page no error is encountered and the search screen closes itsself like it should.

So as far as I can tell its somthing to do with the showl ShowModalDialog call.


Put <base target="_self" /> in the <head> ... </head> section of the page to be displayed in the modal window


You can make use of cross post back

=========

Cross-Page Posting

One common feature in ASP 3.0 that is difficult to achieve in ASP.NET 1.0/1.1 is the capability to do

cross-page posting. Cross-page posting enables you to submit a form (say,Page1.aspx) and have thisform and all the control values post themselves to another page (Page2.aspx).

Traditionally, any page created in ASP.NET 1.0/1.1 simply posted to itself, and you handled the control

values within this page instance. You could differentiate between the page's first request and any postbacks

by using thePage.IsPostBackproperty, as shown here:

If Page.IsPostBack Then

' deal with control values

End If

Even with this capability, many developers still wanted to be able to post to another page and deal with

the first page's control values on that page. This is now possible in ASP.NET 2.0, and it is quite a simple

process.

For an example, create a page calledPage1.aspxthat contains a simple form. This page is shown in

<title>First Page</title>

</head>

<body>

<form id="form1" runat="server">

Enter your name:<br />

<asp:Textbox ID="TextBox1" Runat="server">

</asp:Textbox>

<p>

When do you want to fly?<br />

<asp:Calendar ID="Calendar1" Runat="server"></asp:Calendar></p>

<br />

<asp:Button ID="Button1" Runat="server" Text="Submit page to itself"

OnClick="Button1_Click" />

<asp:Button ID="Button2" Runat="server" Text="Submit page to Page2.aspx"

PostBackUrl="Page2.aspx" />

<p>

<asp:Label ID="Label1" Runat="server"></asp:Label></p>

</form>

</body>

</html>

C#

<%@. Page Language="C#" %>

<script runat="server">

protected void Button1_Click (object sender, System.EventArgs e)

{

Label1.Text = "Hello " + TextBox1.Text + "<br />" +

"Date Selected: " + Calendar1.SelectedDate.ToShortDateString();

}

</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<script runat="server">

protected void Page_Load(object sender, System.EventArgs e)

{

TextBox pp_Textbox1;

Calendar pp_Calendar1;

pp_Textbox1 = (TextBox)PreviousPage.FindControl("Textbox1");

pp_Calendar1 = (Calendar)PreviousPage.FindControl("Calendar1");

Label1.Text = "Hello " + pp_Textbox1.Text + "<br />" + "Date Selected: " +

pp_Calendar1.SelectedDate.ToShortDateString();

}

</script>