[SOLVED] Need Helping Linking Database

This is a discussion on "[SOLVED] Need Helping Linking Database" within the Classic ASP section. This forum, and the thread "[SOLVED] Need Helping Linking Database are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Oct 17th, 2007, 21:15
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Need Helping Linking Database

Well for starters, I have Dreamweaver MX, Windows Vista, MS Access 2007, and IIS7. I am attempting to create a website that requires you to register for a member name, and login. I have followed several tutorials to accomplish this but it never works. I am new to this field and would like to know if anyone has any pointers or advice. I'm not so sure I have my IIS set up correctly either. My biggest problem is getting my ASP form to query the database. I have yet to get my database to show up in the server I made for testing. Like I said before I dont know much about this subject, so any help is greatly appreciated. Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Oct 18th, 2007, 07:30
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

Well, I can help you if you could just post your asp/html page so that I could look at it and perhaps point to you the error.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 18th, 2007, 07:59
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

In IIS you need to set your ODBD connection and define where your site are (wwwroot).
But I suggess that you leave the ODBC connection and use this connection:
Code: Select all
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("yourdatabase.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from tblTable", conn
%>
Quote:
If you are using an ACCESS Database try to avoid using a system DSN. They are much slower because they go through ODBC which then uses the Jet Drivers to access the database. They also have to do a registry lookup. When you use a DSN-LESS connection with ASP theJet Drivers are accessed directly and the performance increase can be dramatic especially with the newer versions of MDAC installed on the server which are especially slow with Access System DSN's.
Source
Beggining ASP and Microsoft Access
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Oct 18th, 2007, 08:26
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

The only thing that you need to do in IIS is this:

Define your site directory where all your page reside,
and set the main page:
Attached Images
File Type: jpg wwwroot.jpg (181.4 KB, 20 views)
File Type: jpg mainpage.jpg (139.1 KB, 14 views)
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Oct 18th, 2007, 09:05
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

Here is a sample full working coding in asp-ccess (add, login, edit, delete) that you will fine quiet interesting to learn from.

Take a look.
Attached Files
File Type: zip SampleASP.zip (16.5 KB, 12 views)
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Oct 19th, 2007, 06:32
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need Helping Linking Database

Quote:
Originally Posted by monie View Post
Well, I can help you if you could just post your asp/html page so that I could look at it and perhaps point to you the error.
Ill be sure to get that posted for you tomorrow. I didnt have a chance today, im at work..nightshift
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Oct 19th, 2007, 06:34
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need Helping Linking Database

Quote:
Originally Posted by monie View Post
In IIS you need to set your ODBD connection and define where your site are (wwwroot).
But I suggess that you leave the ODBC connection and use this connection:
Code: Select all
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("yourdatabase.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from tblTable", conn
%>
Beggining ASP and Microsoft Access

where do i use this connection code...i dont know where to paste that..also how do you set up the dsn?...every time i try it says im using an invalid format or incorrect database type...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Oct 19th, 2007, 06:36
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need Helping Linking Database

btw...thanks for all of your help monie...i know i may be asking some rookie ?'s but ive never done anything like this..its completely new to me..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Oct 19th, 2007, 06:43
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

Quote:
Originally Posted by bjbaughcum03 View Post
Ill be sure to get that posted for you tomorrow. I didnt have a chance today, im at work..nightshift
well honestly, I am not sure about IIS7 and Vista. I am using Windows XP Pro and IIS 5.1

anyway, I am waiting for your asp/html...
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Oct 28th, 2007, 00:03
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need Helping Linking Database

sorry monie bout getting back to so late...ive been busy w/ school...any way here is my code....

HTML: Select all
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/Members.asp" -->
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' *** Redirect if username exists
MM_flag = "MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  Dim MM_rsKey
  Dim MM_rsKey_cmd
  
  MM_dupKeyRedirect = "Registration.html"
  MM_dupKeyUsernameValue = CStr(Request.Form("textfield4"))
  Set MM_rsKey_cmd = Server.CreateObject ("ADODB.Command")
  MM_rsKey_cmd.ActiveConnection = MM_Members_STRING
  MM_rsKey_cmd.CommandText = "SELECT [Email Address] FROM TB_Members WHERE [Email Address] = ?"
  MM_rsKey_cmd.Prepared = true
  MM_rsKey_cmd.Parameters.Append MM_rsKey_cmd.CreateParameter("param1", 200, 1, 255, MM_dupKeyUsernameValue) ' adVarChar
  Set MM_rsKey = MM_rsKey_cmd.Execute
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1, MM_dupKeyRedirect, "?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_Members_STRING
    MM_editCmd.CommandText = "INSERT INTO TB_Members ([First Name], [Last Name], [Date of Birth], [Email Address], Password, [Re-enter Password]) VALUES (?, ?, ?, ?, ?, ?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("textfield")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 255, Request.Form("textfield2")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 202, 1, 255, Request.Form("textfield3")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 255, Request.Form("textfield4")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 202, 1, 255, Request.Form("textfield5")) ' adVarWChar
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param6", 202, 1, 255, Request.Form("textfield6")) ' adVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    ' append the query string to the redirect URL
    Dim MM_editRedirectUrl
    MM_editRedirectUrl = "Home.html"
    If (Request.QueryString <> "") Then
      If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0) Then
        MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
      Else
        MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
      End If
    End If
    Response.Redirect(MM_editRedirectUrl)
  End If
End If
%><!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>FL XL Registration</title>
</head>

<body>
  <form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
    <table width="521" border="0">
      <tr>
        <td width="183"><div align="right">First Name:</div></td>
        <td width="153"><input type="text" name="textfield" id="textfield" /></td>
        <td width="171">&nbsp;</td>
      </tr>
      <tr>
        <td><div align="right">Last Name:</div></td>
        <td><input type="text" name="textfield2" id="textfield2" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div align="right">Date of Birth:</div></td>
        <td><input type="text" name="textfield3" id="textfield3" /></td>
        <td>Example: 10/26/2007</td>
      </tr>
      <tr>
        <td><div align="right">E-mail Address:</div></td>
        <td><input type="text" name="textfield4" id="textfield4" /></td>
        <td>Example: jsmith@gmail.com</td>
      </tr>
      <tr>
        <td><div align="right">Password:</div></td>
        <td><input type="password" name="textfield5" id="textfield5" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td><div align="right">Re-enter Password:</div></td>
        <td><input type="password" name="textfield6" id="textfield6" /></td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input type="submit" name="button" id="button" value="Submit" /></td>
        <td>&nbsp;</td>
      </tr>
    </table>
  
    <input type="hidden" name="MM_insert" value="form1" />
  </form>
  <p>&nbsp;</p>
</div>
</body>
</html>


Dreamweaver seems to access my database, bc it shows up under my connection and shows me the input columns and what not...but when i go to insert data using my website i get this error message from my web browser "An error occurred on the server when processing the URL. Please contact the system administrator" i thought this error might be in my user privileges but its not...bc i changed those to give my self full control...any ideas are greatly appreciated..thanks

Last edited by karinne; Oct 29th, 2007 at 17:26.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Oct 28th, 2007, 00:04
Junior Member
Join Date: Oct 2007
Location: Alabama
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need Helping Linking Database

sorry monie...im not sure how to paste my code where it is in the actual format on here...sorry
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Oct 28th, 2007, 07:55
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,765
Thanks: 0
Thanked 14 Times in 14 Posts
Re: Need Helping Linking Database

Put it between the [ html][/html ] tags (remove the space )
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Oct 28th, 2007, 15:25
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Need Helping Linking Database


[html]
CODE HERE
[/html]


Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Oct 28th, 2007, 15:26
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,765
Thanks: 0
Thanked 14 Times in 14 Posts
Re: Need Helping Linking Database

How the hell did you do that?
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Oct 29th, 2007, 07:31
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,611
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Re: Need Helping Linking Database

Quote:
Originally Posted by bjbaughcum03 View Post
sorry monie...im not sure how to paste my code where it is in the actual format on here...sorry
What are you guys talking? What he mean was this code:
Code: Select all
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("yourdatabase.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from tblTable", conn
%>
The page that you are creating (using DW) generated an auto code for you. If you want to use my code, you'll have to throu away all your code and use a brand new one.. much more simple and short!

Visit my sticky thread: ASP Learning Resources for Beginners here I have posted some of the basic ASP tutorial such as making a database connection, update, edit and delete function.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #16  
Old Oct 29th, 2007, 16:58
Junior Member