Google Answers Logo
View Question
 
Q: ASP.NET appliication ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: ASP.NET appliication
Category: Computers > Programming
Asked by: jmanels-ga
List Price: $50.00
Posted: 11 Feb 2003 07:13 PST
Expires: 13 Mar 2003 07:13 PST
Question ID: 159913
I need help with the source code and the set up of my computer (stand
alone) to access a SQL server databse using and ASP.NET form.

Request for Question Clarification by mathtalk-ga on 11 Feb 2003 07:21 PST
Hi, jmanels-ga:

Is the SQL Server database on your local machine?  Are you doing
development in one location but will want to "move" the application to
a "production" configuration?

You mention help with "source code" and "set up of my computer (stand
alone)", so I'm trying to make a "picture" of what your project is
about.  Do you have VS.Net installed or just the .Net framework? 
Which .Net supported OS are you running?

regards, mathtalk-ga

Clarification of Question by jmanels-ga on 11 Feb 2003 12:54 PST
I am running the SQL server on my machine. Everting is on my machine.
I am trying to build an application that will query the SQL database
and allow me to update records.

I am running Windows 2000 pro with Microsoft net framework SDK, and
I'm trying to use ASP.NET. These files are ***.aspx but they don't do
what I expect when I run them in Internaet Explorer 6.0

I hope this clarifies the sutuation.

   Thanks John

Request for Question Clarification by mathtalk-ga on 11 Feb 2003 19:52 PST
Are you aware that you need to install IIS as well as having Internet
Explorer?  IIS is on the W2K pro install CD but is not part of the
default installation.

regards, mathtalk

Clarification of Question by jmanels-ga on 12 Feb 2003 04:11 PST
Yes I am. I have IIS installed and the "IIS Admin Service" is running.
I am running Internet Explorer version 6.0.2800.1106.

                  Thanks John

Request for Question Clarification by mathtalk-ga on 12 Feb 2003 06:29 PST
Hi, John:

Okay, how about showing me the URL you use for a typical page and
saying what that URL does "wrong" when you pull it up in your browser?
 I think we should verify that ASP.Net stuff is working and then look
into the data access components to see if there's a problem there.  I
have a setup which is fairly similar to yours (desktop W2k pro and
laptop XP pro, both with SQL Server).

regards, mathtalk

Clarification of Question by jmanels-ga on 12 Feb 2003 15:08 PST
The URL I'm trying to run is:

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

<html>
   <head>
      <link rel="stylesheet"href="intro.css">
   </head>

   <script language="VB" runat=server>

       Sub SubmitBtn_Click(Sender As Object, E As EventArgs)

          Dim DS As DataSet
          Dim MyConnection As SqlConnection
          Dim MyCommand As SqlDataAdapter

          MyConnection = New
SqlConnection("server=john;database=pubs;Trusted_Connection=yes")
          MyCommand = New SqlDataAdapter("select * from Titles where
type='" + Category.SelectedItem.Value + "'", myConnection)

          DS = new DataSet()
          MyCommand.Fill(DS, "Titles")

          MyList.DataSource = DS.Tables("Titles").DefaultView
          MyList.DataBind()

       End Sub

   </script>

   <body>

       <center>

       <form action="intro10.aspx" method="post" runat="server">

           <asp:adrotator AdvertisementFile="ads.xml"
BorderColor="black" BorderWidth=1 runat="server"/>

           <h3> Name: <asp:textbox id="Name" runat="server"/>

           Category:  <asp:dropdownlist id="Category" runat=server>
                         <asp:listitem >psychology</asp:listitem>
                         <asp:listitem >business</asp:listitem>
                         <asp:listitem >popular_comp</asp:listitem>
                      </asp:dropdownlist>

           </h3>

           <asp:button text="Lookup" OnClick="SubmitBtn_Click"
runat="server"/>

           <p>

           <asp:datalist id="MyList" layout="flow" showfooter=true
borderwidth=0 runat=server>

              <HeaderTemplate>

                 <table cellpadding=1 cellspacing=0 >
                    <tr>
                       <td colspan=4>
                          <b><font face="Verdana" size=3>Product
Listing </font></b>
                       </td>
                    </tr>
                    <tr>
                       <td colspan=4 height=5 bgcolor="000000"></td>
                    </tr>

              </HeaderTemplate>

              <ItemTemplate>
                      <tr>
                          <td colspan=3 style="font-size:10pt">
                              <b><%#
DataBinder.Eval(Container.DataItem, "title_id") %></b>
                              <span> <%#
DataBinder.Eval(Container.DataItem, "title") %> </span>
                          </td>
                          <td align=right style="font-size:10pt">
                              <b><%#
DataBinder.Eval(Container.DataItem, "price", "${0}") %> </b>
                          </td>

                      </tr>
              </ItemTemplate>

              <SeparatorTemplate>
                      <tr>
                          <td colspan=4 height=1
bgcolor="000000"></td>
                      </tr>
              </SeparatorTemplate>

              <FooterTemplate>
                      <tr>
                          <td colspan=4 height=5
bgcolor="000000"></td>
                      </tr>
                  </table>
              </FooterTemplate>

           </asp:datalist>

       </form>

       </center>

   </body>

</html>

The result is:

Name: Category: psychology business popular_comp 
Product Listing  
 
              Thanks John

Request for Question Clarification by mathtalk-ga on 12 Feb 2003 18:15 PST
Hi, John:

Thanks for posting the ASP.Net source, but what I really had in mind
was what URL are you using?  What address are you putting in the
browser?

regards, mathtalk

Clarification of Question by jmanels-ga on 12 Feb 2003 22:09 PST
I think you may have hit the problem. I have been trying to run the
ASPX form from the browser. I am completely blank about how to set up
the URL.

                           Thanks John
Answer  
Subject: Re: ASP.NET appliication
Answered By: mathtalk-ga on 13 Feb 2003 07:54 PST
Rated:5 out of 5 stars
 
Hi, John:

If you have done a "default" installation of IIS, then you should have
a directory c:\inetpub\wwwroot as the "root" of your localhost's Web
publishing.

You can place the *.aspx page there or preferably in a subdirectory,
say:

c:\inetpub\wwwroot\MyApp

which you create for this project.  If the page MyPage.aspx is there
on the physical drive, then you could enter this as the URL in the
browser:

http://localhost/MyApp/MyPage.aspx

Now the .aspx file is processed by IIS before the results are sent to
the browser.

I'm posting this as an answer because it certainly has a possibility
of solving "all your problems", but then again it most likely will
simply expose some new ones.  Please use the "Request Clarification"
button to let me know what you see next; I'm happy to work with you to
get the page working correctly.

The configuration of IIS allows for "virtual directories", i.e.
folders that are physically located other than beneath
\inetput\wwwroot but appear "logically" for Web publishing purposes as
if they were in that hierarchy.  This might be useful, for example, if
your C: drive is tight on space and you wanted to physically locate
the project directory on D:.

regards, mathtalk-ga

Request for Answer Clarification by jmanels-ga on 13 Feb 2003 23:45 PST
I tried what you said and got the following message


Server Error in '/' Application.
--------------------------------------------------------------------------------

The resource cannot be found. 
Description: HTTP 404. The resource you are looking for (or one of its
dependencies) could have been removed, had its name changed, or is
temporarily unavailable. Please review the following URL and make sure
that it is spelled correctly.

Requested Url: /myapp/johntest.aspx


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0;
ASP.NET Version:1.0.3705.0


I know it's something that I've done wrong in my setup but I don't
know where to start.


Thanks for you patience

Request for Answer Clarification by jmanels-ga on 14 Feb 2003 05:50 PST
I was playing around early this morning and somehow I found that the
IIS was running from a different directory, probably set up when I
installed the tutorial for Framework .NET. I copied my ASPX file to
the new directory and it worked great. I know this now solves the
problem I initially sent in but I would appreciate one more
clarification.

How or where do I config the location of the Web Publishing directory?


Thank you very much for your help.


John Manels

Clarification of Answer by mathtalk-ga on 14 Feb 2003 17:10 PST
Hi, John:

Thanks for your kind words and generous rating (and tip!).

I will explain how to change your Web root or "home directory", but
let me follow that up by explaining how to create "virtual
directories" which logically appear inside that to IIS (but can reside
physically someplace else).

Microsoft has gone through a phase of being found of buzz words like
"management console" and "snap-in".  As a result the interface to
configuring basic parameters of IIS has gotten to be a little
unintutive.

There is probably a couple of ways to navigate into the IIS console
"snap-in" on your W2K box.  Two ways begin by opening the Control
Panel (which is under Settings on W2K) and double-clicking on
Administrative Tools.  You will see one icon inside that folder called
Computer Management, and probably another one called Internet Services
Manager.  You can either go inside the Computer Management console and
drill down under "Services and Applications" to "Internet Information
Services", or else simply open the Internet Services Manager which
takes you there directly.

Or, even more simply, go to the Start...Run dialog box and enter
"inetmgr.exe" (which is the executable name for the IIS Administration
Program).

However you get there, you will now have a tree control on the left
with a node/heading "Internet Information Services," and under that
you will have the name of your computer (and other "local" instances
of IIS on your LAN, perhaps).  Under your computer you will find a
folder node called "Web sites" and under that a page node called
"Default Web Site".

Either right click on "Default Web Site" or select it and use the
Action menu (of the "management console" that hosts this tree
control).  One way or the other you will get a menu with "Properties"
as the next to bottom entry.  Choosing "Properties" brings up a tabbed
dialog box that lets us do what we need to here.

Go to the "Home Directory" tab on that dialog.  The upper part of this
has three radio buttons for three mutually exclusive options about
where "content" for the connections to this computer should come from.
 We want the first of these, which is probably what you already have:

When connecting to this resource, the content should come from:

+ A directory located on this computer

O A share located on another computer

O A redirection to a URL

With that top option selected, the rest of the dialog frame consists
of a text box to enter the name of this local directory, i.e. the
"Home Directory" which is set by default to c:\inetpub\wwwroot.  If
you wish it to be something else, or (in your case) you wish it
weren't something else, then you can simply type what directory you
want it to be here, or click the Browse button and navigate there by
using a familiar "browse for folder" tree control dialog.

Naturally you'll need to stop and restart the IIS service in order for
the new root directory change to take effect.  The IIS 5.0 admin tool
has Start/Stop/Pause entries on the Action menu.  The IIS 5.1 admin
tool has a slightly more compact presentation, a single Restart IIS...
dialog that can be found under All Tasks on the Action menu.

It might be a more conservative approach simpy to create a "Virtual
Directory" pointing to wherever you want to set up your "production"
project files, i.e. where you want to locate johntest.aspx.  Go back
to the Action menu, assuming "Default Web Site" is still selected, and
this time click on New > Virtual Directory.  This pulls up a Wizard
that walks you through the creation of the new Virtual Directory.

The advantage of the Virtual Directory approach is that you can have
as many of these as you want, for different projects, whereas there
can be only one "root" directory.  So in a sense it doesn't really
matter what the actual root or Home Directory is for your IIS
installation, because any directory can be made to appear "as if" it
were inside of it.

best wishes, mathtalk

Request for Answer Clarification by jmanels-ga on 14 Feb 2003 20:52 PST
Tried what you said. it worked great, Thanks again.


John Manels

Clarification of Answer by mathtalk-ga on 14 Feb 2003 21:48 PST
Hi, John:

It's like magic (good magic if it works, black magic if you pull your hair out!).

regards,
mathtalk
jmanels-ga rated this answer:5 out of 5 stars and gave an additional tip of: $20.00
Mathtalk-ga has the patience of Job and walked me through to a final
solution very professionally. I only hope my future visits to this
site are as enjoyable and fruitful.

John Manels

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy