ASP DSN-less connection to Access

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default ASP DSN-less connection to Access

    Dear All,

    I have IIS running on Windows XP Pro. On the server is a Access database
    and my ASP pages all under the
    'wwwroot folder'. I have a form on one of the pages(lets say Form1),
    where users input data. I am trying to add
    this data to the database DSN-lessly. I open the connection on a
    seperate page and include it in Form1 somewhat
    like this: <!-- #INCLUDE FILE="conn_QuoOpen.asp"-->

    And in "conn_QuoOpen.asp", I have this to open then connection:

    <%
    dim conn

    Set conn = Server.CreateObject("ADODB.Connection")
    demoFilePath = Server.MapPath("Quo.mdb")
    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &_
    "Data Source=" & demoFilePath & ";"
    %>

    Now for grabbing the data on Form1 and inserting into the database, this
    is what I have:

    function submitme()
    Dim RsdesApp , strSQLdesApp
    strSQLdesApp = "INSERT INTO Quot (Name,Surname)"
    strSQLdesApp = strSQLdesApp & "Values('" &
    Request.form("txtName") & "','" & Request.form("txtSurname") & "')"

    Response.Write strSQLdesApp
    demoConn.execute strSQLdesApp
    demoConn.commit
    Set RsdesApp = Nothing
    end function

    I can't seem to get the data in. What could I be getting wrong or
    missing out here? Appreciate any help given.
    Thanks in advance.

    Regards,
    Suren

    SurenR Guest

  2. Similar Questions and Discussions

    1. Help using Access database connection
      I am using access, but when it connects using the supplied driver in CF MX7 suddenly I can see the full path name under for instance my tables in...
    2. DW8 connection to MS Access database
      I'm new to database design and I've been trying to connect to an MS Database on my local computer. I've been going round in circles trying asp,...
    3. Access DB Connection problems
      Ok, I'm pretty new to this, so please be patient. Here the story. I've got a very simple access database used for people to enroll in training...
    4. ASP & Access connection
      Hi, Is it possible to connect to Access file located on another web server using ASP 3.0? Thanx, Neven
    5. Access sql connection stuff
      strSQL = "INSERT INTO Personal(FirstName,LastName) VALUES('" & strFirstName & "','" & strLastName & "')" tim "middletree"...
  3. #2

    Default Re: ASP DSN-less connection to Access

    "SurenR" <suren81@singnet.com.sg> wrote in message
    news:409C6993.5020905@singnet.com.sg...
    > Dear All,
    >
    > I have IIS running on Windows XP Pro. On the server is a Access database
    > and my ASP pages all under the
    > 'wwwroot folder'. I have a form on one of the pages(lets say Form1),
    > where users input data. I am trying to add
    > this data to the database DSN-lessly. I open the connection on a
    > seperate page and include it in Form1 somewhat
    > like this: <!-- #INCLUDE FILE="conn_QuoOpen.asp"-->
    >
    > And in "conn_QuoOpen.asp", I have this to open then connection:
    >
    > <%
    > dim conn
    >
    > Set conn = Server.CreateObject("ADODB.Connection")
    > demoFilePath = Server.MapPath("Quo.mdb")
    > conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" &_
    > "Data Source=" & demoFilePath & ";"
    > %>
    >
    > Now for grabbing the data on Form1 and inserting into the database, this
    > is what I have:
    >
    > function submitme()
    > Dim RsdesApp , strSQLdesApp
    > strSQLdesApp = "INSERT INTO Quot (Name,Surname)"
    > strSQLdesApp = strSQLdesApp & "Values('" &
    > Request.form("txtName") & "','" & Request.form("txtSurname") & "')"
    >
    > Response.Write strSQLdesApp
    > demoConn.execute strSQLdesApp
    > demoConn.commit
    > Set RsdesApp = Nothing
    > end function
    >
    > I can't seem to get the data in. What could I be getting wrong or
    > missing out here? Appreciate any help given.
    > Thanks in advance.
    >
    > Regards,
    > Suren
    Does the Response.Write look okay?

    What error are you getting?

    If the error is "Operation must use an updateable query.", then under XP
    Pro:

    1) Open Control Panel then click Folder Options then scroll to the
    bottom and turn off "Simple File Sharing"

    2) Open Windows Explorer, right-click on the database's folder, click
    Properties, click on the (now revealed) Security tab then select Everyone
    then click the "Write" checkbox the click "Apply".


    McKirahan Guest

  4. #3

    Default Re: ASP DSN-less connection to Access

    > I can't seem to get the data in.

    What does that mean?

    Are you getting an error message? If so, WHAT IS IT?

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand [MVP] Guest

  5. #4

    Default Re: ASP DSN-less connection to Access

    Hey guys!

    Sorry for the late reply!
    Ive managed to get data into the Access table at the moment. But right
    now I have another problem, here's
    the error message:

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Expected query name after EXECUTE.
    /EnquiryInsert.asp, line 19

    Heres the line of code where the error was reported:

    Ln10 <%
    Ln11 Dim RsdesApp , strSQLdesApp
    Ln12 Set strSQLdesApp = CreateObject("Adodb.Recordset")

    Ln14 strSQLdesApp = "INSERT INTO Quot (Name,Surname) "
    Ln15 strSQLdesApp = strSQLdesApp & "Values('" &
    Request.form("txtName") & "','" & Request.form("txtSurname") & "')"

    Ln17 'Response.Write strSQLdesApp
    Ln18 conn.execute(strSQLdesApp)
    Ln19 conn.commit
    Ln20 Response.Redirect("Enquiry.asp")
    Ln21 conn.close
    Ln22 Set conn = Nothing
    Ln23 Set RsdesApp = Nothing
    Ln24 %>

    Thanks.

    Regards,
    Suren

    Aaron Bertrand [MVP] wrote:
    >>I can't seem to get the data in.
    >>
    >
    >What does that mean?
    >
    >Are you getting an error message? If so, WHAT IS IT?
    >

    SurenR Guest

  6. #5

    Default Re: ASP DSN-less connection to Access

    (a) Why are you using Set strSQLdesApp? As your variable naming explains,
    this is a STRING, not an object.

    (b) Always make sure to prevent SQL injection and syntax errors by replacing
    apostrophes in incoming data with double apostrophes (see
    [url]http://www.aspfaq.com/2035[/url]).

    (c) What the heck do you have conn.commit for? Conn.execute already does
    whatever you think conn.commit will do. Also, you should make sure to tell
    the connection object what kind of command you are using. 129 designates it
    as adCommandText with adExecuteNoRecords (the former improves efficiency
    because the provider knows exactly what kind of command is being sent, and
    doesn't have to translate it by sniffing it out; the latter because it knows
    it will not have to retrieve any data).

    (d) Name is a reserved word. Have you considered using columns like
    FirstName and LastName, which have three advantages: (1) they're far more
    descriptive than Name and Surname; (2) they avoid a reserved word problem;
    and (3) they are far more standard. As it is, you will have to surround
    this column name with [square brackets].

    Taking only (a) (c) and (d) into account:

    <%
    set conn = CreateObject("ADODB.Connection")
    conn.open "<...connection string...>"
    strSQL = "INSERT INTO Quot([Name], Surname) <...the rest here...> "
    conn.execute strSQL, , 129
    conn.close: set conn = nothing
    %>

    (In the future, please post in plain text.)

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]





    "SurenR" <suren81@singnet.com.sg> wrote in message
    news:409F05FF.7070505@singnet.com.sg...
    Hey guys!

    Sorry for the late reply!
    Ive managed to get data into the Access table at the moment. But right now I
    have another problem, here's
    the error message:

    Error Type:
    Microsoft JET Database Engine (0x80040E14)
    Expected query name after EXECUTE.
    /EnquiryInsert.asp, line 19

    Heres the line of code where the error was reported:

    Ln10 <%
    Ln11 Dim RsdesApp , strSQLdesApp
    Ln12 Set strSQLdesApp = CreateObject("Adodb.Recordset")

    Ln14 strSQLdesApp = "INSERT INTO Quot (Name,Surname) "
    Ln15 strSQLdesApp = strSQLdesApp & "Values('" & Request.form("txtName") &
    "','" & Request.form("txtSurname") & "')"

    Ln17 'Response.Write strSQLdesApp
    Ln18 conn.execute(strSQLdesApp)
    Ln19 conn.commit
    Ln20 Response.Redirect("Enquiry.asp")
    Ln21 conn.close
    Ln22 Set conn = Nothing
    Ln23 Set RsdesApp = Nothing
    Ln24 %>

    Thanks.

    Regards,
    Suren

    Aaron Bertrand [MVP] wrote:

    I can't seem to get the data in.
    What does that mean?Are you getting an error message? If so, WHAT IS IT?


    Aaron Bertrand [MVP] Guest

Posting Permissions

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

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 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139