1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

what is wrong with this code because it did not work?

Discussion in 'JavaScript' started by mohammed gorashy, Oct 12, 2023.

  1. #2
    if (typeof ActiveXObject !== "undefined") {
    var adoconn = New ActiveXobject("ADODB.Connection");
    var adors = New ActiveXObject("ADODB.Recordset");
    adoconn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source ='/\book.mdb'");
    adors.open("beginner",adoconn,1,3);
    var str = adors.fields("questions").value;
    window.alert(str)
    }
    Code (markup):

     
    Last edited by a moderator: Oct 12, 2023
    mohammed gorashy, Oct 12, 2023 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,507
    Likes Received:
    4,460
    Best Answers:
    123
    Trophy Points:
    665
    #3
    This might not be the best place to ask. I doubt any of us have ever worked with ActiveX and it was discontinued years ago.
     
    sarahk, Oct 12, 2023 IP
    deathshadow likes this.
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    THIS. Not only that, but it only ever worked in Internet Explorer which... well... it's 2023, who the blazes is still using IE? And even in IE it started being disabled by default as a security flaw sometime around 2007.
     
    deathshadow, Oct 17, 2023 IP
  4. What is Cornhole?

    What is Cornhole? Peon

    Messages:
    29
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    3
    #5
    Have AI (like ChatGPT or Google Bard) write the code for you and compare to yours. I'll bet you'll find the error :).
     
    What is Cornhole?, Oct 19, 2023 IP
    sarahk likes this.
  5. Mark Elijah

    Mark Elijah Greenhorn

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #6
    The code might have compatibility issues (for older browsers) or syntax errors. Check the file path and for typos (especially capitalization).
     
    Mark Elijah, Apr 8, 2024 IP
  6. MargoFarrel

    MargoFarrel Member

    Messages:
    164
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    33
    #7
    Here’s the corrected JavaScript code:



    if (typeof ActiveXObject !== "undefined") {
    var adoconn = new ActiveXObject("ADODB.Connection");
    var adors = new ActiveXObject("ADODB.Recordset");
    adoconn.open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source='\\\\book.mdb'");
    adors.open("beginner", adoconn, 1, 3);
    var str = adors.fields("questions").value;
    console.log(str);
    } else {
    console.log("ActiveXObject is not available in this environment.");
    }
     
    MargoFarrel, Apr 9, 2024 IP
  7. Wale Jesukoya

    Wale Jesukoya Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #8
    The code you provided has a couple of issues that would prevent it from working in modern environments:



    1. ActiveXObject Deprecation: The primary issue is the use of ActiveXObject. ActiveXObject is an Internet Explorer (IE) specific way to create objects. It's not supported in modern browsers and has been deprecated for a long time.

    2. Syntax Error: There's a minor syntax error in the first line where it says New ActiveXobject instead of new ActiveXObject (lowercase 'n').
    Here's a breakdown of the limitations:

    • Non-functional in most browsers: Since ActiveXObject is specific to IE, the code wouldn't work in other browsers like Firefox, Chrome, or Safari.
    • Security Concerns: ActiveX has security vulnerabilities and is generally discouraged in modern development.
    If you're aiming for broader browser compatibility, you'll need to abandon ActiveX and explore alternative approaches for database access or data manipulation depending on your goal.

    Here are some possible alternatives depending on your scenario:

    • Web APIs: If you're working with a web application and need to access data from a server-side database, consider using Web APIs like REST or GraphQL. These provide a standardized way to communicate with a server and retrieve data.
    • IndexedDB: If you're working with a client-side application and need to store data locally in the browser, you can explore IndexedDB, a browser API for storing data on the client-side.
     
    Wale Jesukoya, Apr 10, 2024 IP