www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: ASP Database Connection

  1. #1
    Join Date
    Nov 2011
    Posts
    8

    ASP Database Connection

    HI

    I have made a .asp guestbook that works with a .mdb database.

    Everything works fine on my PC (IIS).

    Now i uploaded the page, the DB and the connection but i cant get the connection to work i just keep getting diffrent errors over and over.


    If i do this:
    Code:
    <%
    // FileName="Connection_odbc_conn_dsn.htm"
    // Type="ADO" 
    // DesigntimeType="ADO"
    // HTTP="false"
    // Catalog=""
    // Schema=""
    Set Conn =Server.CreateObject(ADODB.Connection);
    strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid="Admin";Pwd="xxxx"";
    oConn.Open(strConnection);
    %>
    I get an error in my connection file:
    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /twentyonedays/Connections/Guestbook.asp, line 8

    Set Conn =Server.CreateObject(ADODB.Connection);


    If i do this:
    Code:
    <%
    // FileName="Connection_odbc_conn_dsn.htm"
    // Type="ADO" 
    // DesigntimeType="ADO"
    // HTTP="false"
    // Catalog=""
    // Schema=""
    strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=xxxxx";
    %>
    I get an error in my site (not the connection)
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'

    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

    /twentyonedays/Gaestebuch.asp, line 43

    Line 43 sais:
    Code:
    rsGuestbook_cmd.ActiveConnection = MM_Guestbook_STRING;
    I hope i could give enough information and someone can maybe help me.


    Regards
    Robin!

  2. #2
    Join Date
    Sep 2011
    Posts
    60
    as i remember line
    Set Conn =Server.CreateObject(ADODB.Connection);
    shoiuuld be
    Set Conn =Server.CreateObject("ADODB.Connection")


    and it is no ; on the end of each line it is classic asp

  3. #3
    Join Date
    Nov 2011
    Posts
    8
    Code:
    <%
    dim Conn
    set Conn = Server.CreateObject("ADODB.Connection")
    strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=mentos";
    oConn.Open(strConnection)
    %>
    Gives me this error msg:
    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /twentyonedays/Connections/Guestbook.asp, line 2

    dim Conn
    ----^

  4. #4
    Join Date
    Sep 2011
    Posts
    60
    you do not need to dim anything

  5. #5
    Join Date
    Nov 2011
    Posts
    8
    If i remove the "dim"

    Code:
    <%
    set Conn = Server.CreateObject("ADODB.Connection")
    strConnection="Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=/Twentyonedays/db/guestbook2000.mdb;Uid=Admin;Pwd=xxxxxx";
    oConn.Open(strConnection)
    %>
    I get this error and i dont understand whats wrong with the line:

    Microsoft JScript compilation error '800a03ec'

    Expected ';'

    /twentyonedays/Connections/Guestbook.asp, line 2

    set Conn = Server.CreateObject("ADODB.Connection")
    ----^

  6. #6
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    Your semicolon is outside the quotes, it should be inside.

    Pwd=xxxxxx;"

  7. #7
    Join Date
    Nov 2011
    Posts
    8
    Hi guys to give it a little update: I still cant get it too work so i decided to post my code maybe some1 can give me a hand: I would be so thankfull

    The page that uses the Database looks like this
    Code:
    <%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
    <!--#include file="Connections/gb.asp" -->
    <%
    var rsGB_cmd = Server.CreateObject ("ADODB.Command");
    rsGB_cmd.ActiveConnection = MM_gb_STRING;
    rsGB_cmd.CommandText = "SELECT * FROM Guestbook";
    rsGB_cmd.Prepared = true;
    
    var rsGB = rsGB_cmd.Execute();
    var rsGB_numRows = 0;
    %>
    <%
    var Repeat1__numRows = 10;
    var Repeat1__index = 0;
    rsGB_numRows += Repeat1__numRows;
    %>
    The connection looks like this
    Code:
    <%
    // FileName="Connection_odbc_conn_dsn.htm"
    // Type="ADO" 
    // DesigntimeType="ADO"
    // HTTP="false"
    // Catalog=""
    // Schema=""
    var MM_gb_STRING = "dsn=Guestbook;"
    strConnection = "DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/twentyonedays/db/guestbook2000.mdb")
    %>
    And this is the error i get
    Code:
    Microsoft OLE DB Provider for ODBC Drivers error '80004005'
    
    [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
    
    /twentyonedays/Connection test.asp, line 5
    I am using no password for testing purpose now.

  8. #8
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    This WILL work for a DSN-less connection

    Code:
    	Set Conn=Server.CreateObject("ADODB.Connection")
    	Conn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    	"DATA SOURCE=" & server.mappath("twentyonedays/db/guestbook2000.mdb")
    
    sql = "select * from Guestbook"
    set rs=Conn.Execute(sql)
    do until rs.eof
     response.write rs(0) & "<br>"
    rs.movenext
    loop
    rs.close
    set rs=nothing

  9. #9
    Join Date
    Nov 2011
    Posts
    8
    Thanks alot for your help!!!

    But i get this error always when i use this line
    Set Conn=Server.CreateObject("ADODB.Connection")
    Code:
    Microsoft JScript compilation error '800a03ec'
    
    Expected ';'
    
    /twentyonedays/db/Guestbook.asp, line 2
    
    Set Conn=Server.CreateObject("ADODB.Connection")
    ----^

  10. #10
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    That's because your using Javascript instead of VBscript. You will need to re-write slightly to accommodate that.

  11. #11
    Join Date
    Nov 2011
    Posts
    8
    Thank you soo much for your help!!! I have changed the code to VBSkript.

    I have got the connection running but i still have a bug. Somehow before the page even starts i get this:
    Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    http://users8.jabry.com/twentyonedays/Guestbooktest.asp Here is a link to the page. Thanks ALOT!
    Last edited by Twentyonedays; 11-08-2011 at 01:52 PM.

  12. #12
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227

  13. #13
    Join Date
    Nov 2011
    Posts
    8
    The actual site:
    Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include file="Connections/Guestbook.asp" -->
    <%
    Dim rsGuestbook
    Dim rsGuestbook_cmd
    Dim rsGuestbook_numRows
    
    Set rsGuestbook_cmd = Server.CreateObject ("ADODB.Command")
    rsGuestbook_cmd.ActiveConnection = MM_Guestbook_STRING
    rsGuestbook_cmd.CommandText = "SELECT * FROM Guestbook" 
    rsGuestbook_cmd.Prepared = true
    
    Set rsGuestbook = rsGuestbook_cmd.Execute
    rsGuestbook_numRows = 0
    %>
    The connection string:
    Code:
    <%
    Dim MM_Guestbook_STRING
    Set MM_Guestbook_STRING = Server.CreateObject("ADODB.Connection")
    	MM_Guestbook_STRING.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
    	"DATA SOURCE=" & Server.MapPath("/twentyonedays/db/guestbook2000.mdb")
    sql = "select * from Guestbook"
    set rs=MM_Guestbook_STRING.Execute(sql)
    do until rs.eof
     response.write rs(0) & "<br>"
    rs.movenext
    loop
    rs.close
    set rs=nothing
    %>

  14. #14
    Join Date
    Sep 2011
    Posts
    60
    sure and you have i gues 25 records in your guestbook
    that lopp creates that

    Code:
    do until rs.eof
     response.write rs(0) & "<br>"
    rs.movenext
    loop
    rs.close

  15. #15
    Join Date
    Nov 2011
    Posts
    8
    THANK YOU ALL ALOT!!!!! You were so helpfull!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.12634 seconds
  • Memory Usage 3,006KB
  • Queries Executed 13 (?)
More Information
Template Usage (37):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (14)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (15)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (15)postbit
  • (15)postbit_onlinestatus
  • (15)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates