CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2010
    Posts
    3

    Unhappy Help with ASP.net file

    Hello,

    I need help with Asp.net file.

    I am trying to create a website that will take input from user, and when user clicks submit, it will run the asp.net file which will take the data and place it into a MS Access Table.

    I have created the html page, the asp.net file and the db.

    But when user clicks Submit, a pop up comes up that asks user to either open, save or cancel the asp.net file.

    What am I doing wrong. Here is the code from the Asp.net file:
    <% @ Language="VBScript" %>
    <% Option Explicit %>
    <html>
    <head>
    <title>Form to database</title>
    </head>
    <body>
    <%
    'declare your variables
    Dim Card#, FirstName, LastName, DOB, CellPhone, Gender, StoreName, EmailAddress
    Dim sConnString, connection, sSQL

    ' Receiving values from Form, assign the values entered to variables
    Card# = Request.welcome.html("Card#")
    FirstName = Request.welcome.html("FirstName")
    LastName =Request.welcome.html("LastName")
    DOB =Request.welcome.html("DOB")
    CellPhone =Request.welcome.html("CellPhone")
    Gender =Request.welcome.html("Gender")
    StoreName =Request.welcome.html("StoreName")
    EmailAddress =Request.welcome.html("EmailAddress")

    'declare SQL statement that will query the database
    sSQL = "INSERT into G&L Table (Card#, First Name, Last Name, DOB, Cell Phone, Gender, Store Name, Email Address) values ('" & Card# & "', '" & FirstName & "', '" & LastName & "', '" & DOB & "', '" & CellPhone & "', '" & Gender & "', '" & StoreName & "','" & EmailAddress & "',)"

    'define the connection string, specify database
    'driver and the location of database
    sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Server.MapPath("Test1.accdb")


    'create an ADO connection object
    Set connection = Server.CreateObject("ADODB.Connection")

    'Open the connection to the database
    connection.Open(sConnString)

    'execute the SQL
    connection.execute(sSQL)

    response.write "The form information was inserted successfully."

    ' Done. Close the connection object
    connection.Close
    Set connection = Nothing
    %>
    </body>
    </html>

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: Help with ASP.net file

    Can we see the code for the HTML file?

    It sounds like either you're web server is not configured to handle asp files, or your HTML page is coded incorrectly.
    Last edited by Craig Gemmill; October 1st, 2010 at 11:06 AM. Reason: This is actually an ASP question, not a ASP.NET question.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  3. #3
    Join Date
    Sep 2010
    Posts
    3

    Re: Help with ASP.net file

    Here is the code from the body of the html file

    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    #apDiv1 {
    position:absolute;
    left:2px;
    top:75px;
    width:11552px;
    height:0px;
    z-index:1;
    }
    body,td,th {
    font-size: 18px;
    color: #000033;
    }
    body {
    background-color: #FFFBF0;
    background-image: url();
    background-repeat: no-repeat;
    }
    .style11 {font-size: 16px; color: #FF0000; }
    .style8 {font-size: 16px}
    .style9 {font-weight: bold; color: #FF0000; }
    -->
    </style>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="posttodb.asp">
    <label></label>
    <label></label>
    <table width="1066" height="191" border="0">

    <tr>
    <td width="138"><label>Card# </label></td>
    <td width="912"><input type="text" name="Card#" id="Card#" /></td>
    </tr>
    <tr>
    <td><label>FirstName </label></td>
    <td><input type="text" name="FirstName" id="FirstName" /></td>
    </tr>
    <tr>
    <td>LastName</td>
    <td><input type="text" name="Last Name" id="Last Name" /></td>
    </tr>
    <tr>
    <td><label>DOB </label></td>
    <td><label>
    <input type="text" name="DOB" id="DOB" />
    </label></td>
    </tr>
    <tr>
    <td><label>CellPhone </label></td>
    <td><label>
    <input type="text" name="CellPhone" id="CellPhone" />
    </label></td>
    </tr>
    <tr>
    <td><label>EmailAddress</label></td>
    <td><input type="text" name="EmailAddress" id="EmailAddress" /></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><label>
    <input type="radio" name="Gender" value="radio" id="Gender_0" />
    Male</label>
    <br />
    <label>
    <input type="radio" name="Gender" value="radio" id="Gender_1" />
    Female</label></td>
    </tr>
    <tr>
    <td><label>StoreName </label></td>
    <td><label>
    <input type="text" name="StoreName" id="StoreName" />
    </label></td>
    </tr>
    </table>
    <p>

    </form>
    </body>
    </html>


    Thanks

  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: Help with ASP.net file

    Yeah, you have to run that page from a web server that supports ASP (IIS for example). You cannot just execute ASP scripting on your desktop.
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  5. #5
    Join Date
    Sep 2010
    Posts
    3

    Re: Help with ASP.net file

    Now I keep getting an internal server error as soon as I clik on Submit.

    The code looks ok right?

    Any ideas?

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Help with ASP.net file

    What server do you have? Did you install the ASP batch file from VS2010?

    If you didn't have IIS installed when you installed VS2010, it doesn't load it
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured