<% Response.Buffer = true %> <% Dim RecordSet, strSQL, strUsername strUsername = Request.Form("Username") strSQL = "SELECT Alias FROM StaffList" Set RecordSet = Server.CreateObject("ADODB.Recordset") RecordSet.Open strSQL, databaseConnection Do Until RecordSet.EOF If(StrComp(RecordSet("Alias"), strUsername) = 0) Then Response.Write ("You are staff") Else RecordSet.MoveNext Loop RecordSet.Close Set RecordSet = Nothing databaseConnection.Close Set databaseConnection = Nothing %> The ASP code for connection.asp: <% Dim databaseConnection Set databaseConnection = Server.CreateObject("ADODB.Connection") databaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/intranet/IntranetDB.mdb") & ";" databaseConnection.Open %> Please tell me what do you observe? I'm really stuck. Thank you. [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => tabonni [ip] => tabonni@yahoo.c [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> > <% Response.Buffer = true %> > <% > > Dim RecordSet, strSQL, strUsername > > strUsername = Request.Form("Username") > > strSQL = "SELECT Alias FROM StaffList" > > Set RecordSet = Server.CreateObject("ADODB.Recordset") > RecordSet.Open strSQL, databaseConnection > > Do Until RecordSet.EOF > If(StrComp(RecordSet("Alias"), strUsername) = 0) Then > Response.Write ("You are staff") > Else > RecordSet.MoveNext > Loop > > RecordSet.Close > Set RecordSet = Nothing > databaseConnection.Close > Set databaseConnection = Nothing > %> > > The ASP code for connection.asp: > <% > Dim databaseConnection > Set databaseConnection = Server.CreateObject("ADODB.Connection") > databaseConnection.ConnectionString = > "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & > Server.MapPath("/intranet/IntranetDB.mdb") & ";" > databaseConnection.Open > %> > > Please tell me what do you observe? I'm really stuck. > > Thank you.[/ref] Take a closer look at your code: Do Until RecordSet.EOF If(StrComp(RecordSet("Alias"), strUsername) = 0) Then Response.Write ("You are staff") Else RecordSet.MoveNext Loop When there's a match you're in an infinite loop! Either add "RecordSet.MoveNext" after your "Response.Write()" or, better yet, write asn effective SQL statement; something like: strSQL = "SELECT Alias FROM StaffList" strSQL = strSQL & " WHERE Alias ='" & strUsername &"'" If Not RecordSet.EOF Then Response.Write ("You are staff") End If [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => McKirahan [ip] => News@McKirahan. [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 2 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> <% Response.Buffer = true %> <% Dim RecordSet, strUsername,strSQL strUsername = TRIM(Request.Form("Username")) strSQL = "SELECT [Alias] FROM StaffList WHERE [Alias]='" & strUsername & "'" Set RecordSet = Server.CreateObject("ADODB.Recordset" RecordSet.Open strSQL, databaseConnection If NOT RecordSet.EOF Then Response.Write "You are staff" Else Response.Write "You are NOT staff" End If RecordSet.Close Set RecordSet = Nothing databaseConnection.Close Set databaseConnection = Nothing %> I'm wondering it is something wrong on the procedure when I connect the MS Exchange to MS Access. [New Table -> Link Table -> File of Type [I choose Exchange()] -> Choose "Global Adress List" -> Rename to "StaffList -> Finish]. I tried to choose Exchange() and Outlook(). But, I still can't make it work. BTW, what's the difference between Exchange() and Outlook()? Thank you. "Ray Costanzo [MVP]" wrote in message news:...[ref] > Not to mention he could just make use of a WHERE clause and skip the loop > altogether. > > Ray at work > > "McKirahan" wrote in message > news:ASrbd.238350$.. >[ref] > > > > Take a closer look at your code: > > > > Do Until RecordSet.EOF > > If(StrComp(RecordSet("Alias"), strUsername) = 0) Then > > Response.Write ("You are staff") > > Else > > RecordSet.MoveNext > > Loop > > > > When there's a match you're in an infinite loop! > > > > Either add "RecordSet.MoveNext" after your "Response.Write()" or, better > > yet, write asn effective SQL statement; something like: > > > > strSQL = "SELECT Alias FROM StaffList" > > strSQL = strSQL & " WHERE Alias ='" & strUsername &"'" > > > > If Not RecordSet.EOF Then > > Response.Write ("You are staff") > > End If > > > >[/ref][/ref] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => tabonni [ip] => tabonni@yahoo.c [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 5 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Problem on querying Access link table in ASP page - ASP Database

Problem on querying Access link table in ASP page - ASP Database

Hi All I connected MS Exchange Server to MS Access database using Access link table function. I can open the database table and see the fields and data inside the link table. However, the table seems cannot be queried by SQL statement. My situation is: I'm building an intranet. I have a ASP login page for all staff in the company to login. Other people can't register or login the intranet. That's the reason I use the company email address to verify username login name. After I made the link to the Global Address List (rename to StaffList), I can ...

  1. #1

    Default Problem on querying Access link table in ASP page

    Hi All

    I connected MS Exchange Server to MS Access database using Access link
    table function. I can open the database table and see the fields and
    data inside the link table. However, the table seems cannot be queried
    by SQL statement.

    My situation is:
    I'm building an intranet. I have a ASP login page for all staff in the
    company to login. Other people can't register or login the intranet.
    That's the reason I use the company email address to verify username
    login name.

    After I made the link to the Global Address List (rename to
    StaffList), I can see the Alias field. I wrote ASP code to use Alias
    field to verify user login name. But, the ASP page seems experiencing
    difficulties. I always got the "Connection Timeout" Error.

    The procedure I connect Exchange to Access:
    [New Table -> Link Table -> File of Type [I choose Exchange()] ->
    Choose "Global Adress List" -> Rename to "StaffList -> Finish]

    My ASP code is as follow:

    <% Language=VBScript %>
    <!-- #INCLUDE VIRTUAL="/intranet/connection.asp" -->
    <% Response.Buffer = true %>
    <%

    Dim RecordSet, strSQL, strUsername

    strUsername = Request.Form("Username")

    strSQL = "SELECT Alias FROM StaffList"

    Set RecordSet = Server.CreateObject("ADODB.Recordset")
    RecordSet.Open strSQL, databaseConnection

    Do Until RecordSet.EOF
    If(StrComp(RecordSet("Alias"), strUsername) = 0) Then
    Response.Write ("You are staff")
    Else
    RecordSet.MoveNext
    Loop

    RecordSet.Close
    Set RecordSet = Nothing
    databaseConnection.Close
    Set databaseConnection = Nothing
    %>

    The ASP code for connection.asp:
    <%
    Dim databaseConnection
    Set databaseConnection = Server.CreateObject("ADODB.Connection")
    databaseConnection.ConnectionString =
    "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
    Server.MapPath("/intranet/IntranetDB.mdb") & ";"
    databaseConnection.Open
    %>

    Please tell me what do you observe? I'm really stuck.

    Thank you.
    tabonni Guest

  2. #2

    Default Re: Problem on querying Access link table in ASP page

    "tabonni" <com> wrote in message
    news:google.com... 


    Take a closer look at your code:

    Do Until RecordSet.EOF
    If(StrComp(RecordSet("Alias"), strUsername) = 0) Then
    Response.Write ("You are staff")
    Else
    RecordSet.MoveNext
    Loop

    When there's a match you're in an infinite loop!

    Either add "RecordSet.MoveNext" after your "Response.Write()" or, better
    yet, write asn effective SQL statement; something like:

    strSQL = "SELECT Alias FROM StaffList"
    strSQL = strSQL & " WHERE Alias ='" & strUsername &"'"

    If Not RecordSet.EOF Then
    Response.Write ("You are staff")
    End If


    McKirahan Guest

  3. #3

    Default Re: Problem on querying Access link table in ASP page

    "McKirahan" <com> wrote in message
    news:ASrbd.238350$.. 

    [snip]

    Take another closer look at your code:

    Do Until RecordSet.EOF
    If(StrComp(RecordSet("Alias"), strUsername) = 0) Then
    Response.Write ("You are staff")
    Else
    RecordSet.MoveNext
    Loop

    Where's your "End If"? Perhaps you wanted:

    Do Until RecordSet.EOF
    If(StrComp(RecordSet("Alias"), strUsername) = 0) Then
    Response.Write ("You are staff")
    Exit Do
    End If
    RecordSet.MoveNext
    Loop

    But (as I said before) why loop through the entire recordset for one
    record?!


    McKirahan Guest

  4. #4

    Default Re: Problem on querying Access link table in ASP page

    Not to mention he could just make use of a WHERE clause and skip the loop
    altogether.

    Ray at work

    "McKirahan" <com> wrote in message
    news:ASrbd.238350$..
     


    Ray Guest

  5. #5

    Default Re: Problem on querying Access link table in ASP page

    I changed my code, but I still can't make it work. Sometimes, I got
    "Microsoft JET Database Engine (0x80004005)The Microsoft Jet database
    engine has already been initialized.", after I enter the username and
    press submit button.

    Sometimes,the page took a long time to load and got "Connection
    Timeout Error" Eventually.

    Because Alias is the field name of Exchange table. So, I need to put
    Alias as [Alias] in SQL statment. I changed code as follow:

    <% Language=VBScript %>
    <!-- #INCLUDE VIRTUAL="/intranet/connection.asp" -->
    <% Response.Buffer = true %>
    <%
    Dim RecordSet, strUsername,strSQL
    strUsername = TRIM(Request.Form("Username"))
    strSQL = "SELECT [Alias] FROM StaffList WHERE [Alias]='" & strUsername
    & "'"
    Set RecordSet = Server.CreateObject("ADODB.Recordset"
    RecordSet.Open strSQL, databaseConnection
    If NOT RecordSet.EOF Then
    Response.Write "You are staff"
    Else
    Response.Write "You are NOT staff"
    End If

    RecordSet.Close
    Set RecordSet = Nothing
    databaseConnection.Close
    Set databaseConnection = Nothing
    %>

    I'm wondering it is something wrong on the procedure when I connect
    the MS Exchange to MS Access.
    [New Table -> Link Table -> File of Type [I choose Exchange()] ->
    Choose "Global Adress List" -> Rename to "StaffList -> Finish].

    I tried to choose Exchange() and Outlook(). But, I still can't make it
    work. BTW, what's the difference between Exchange() and Outlook()?

    Thank you.



    "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<phx.gbl>... [/ref]
    tabonni Guest

  6. #6

    Default Re: Problem on querying Access link table in ASP page

    If you are using an exchange server then you have to be running an
    active directory server

    there is a easier way of doing this with out linking an exchange table
    to the access db

    you make it so that the login page submits to a script that takes there
    username and password and varifies that with an ldap object on the
    domain

    the sample below uses the full e-maill (com)

    just replace the somedomain with your domain name (and the com with your
    extension (may be .local)


    'Start Sample Code
    Dim dso
    Dim obj1
    dim msUserName
    dim msPassWord

    msUserName = Request.Form("UserName")
    msPassWord = Request.Form("Password")

    Set dso = GetObject("LDAP:")
    on error resume next
    ' Supply full credentials to initiate a server connection.
    Set obj1 = dso.OpenDSObject( _
    "LDAP://somedomain.com/DC=somedomain,DC=com", _
    msUserName, _
    msPassword, _
    ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)

    if err.number <> 0 then
    'The Loging failed
    else
    'The User and pass are valid
    end if
    'End Sample Code

    as long as your web server is part of the domain you shouldn't have any
    problem in resolveing the ldap server.



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Stephen Guest

Similar Threads

  1. MS Access with Mysql link table connection failed
    By pelhughes in forum Coldfusion Database Access
    Replies: 3
    Last Post: July 3rd, 11:13 PM
  2. Problem querying Access DB for records within a certaindate range.
    By liquidorb in forum Coldfusion Database Access
    Replies: 5
    Last Post: January 19th, 03:25 AM
  3. querying field / column names in Access table
    By Brian Gallutia in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: April 28th, 07:05 PM
  4. Problem querying data from Access
    By fix in forum ASP Database
    Replies: 5
    Last Post: August 19th, 04:49 AM
  5. Replies: 6
    Last Post: June 30th, 11:56 PM

Bookmarks

Posting Permissions

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