Results 1 to 6 of 6

Thread: Data Updation / Adding problem using ASP.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80

    Data Adding/Updating problem using ASP

    Hi every body.

    PROBLEM----------
    ODBS DRIVER ERROR
    DATABASE OR OBJECT IS READONLY




    CODE----------------------------------------

    db=Server.MapPath("MyStore.mdb")

    Provider=MSDASQL & "Mode = Read|Write" & "DBQ=" & db & ";Driver={Microsoft Access Driver (*.mdb)}" & "DSN='MYSTORE' " & "UserCommitSync='Yes' "
    set conn=server.createobject("adodb.connection")

    conn.open session("dblog")

    Set rsproducts = Server.CreateObject("ADODB.Recordset")
    IPN=REQUEST.FORM("TXTIPN")
    sSQL = "SELECT * FROM products where itemproductnumber like '" & _
    IPN & "'"

    rsproducts.open sSQL ,conn,adOpenStatic ,adLockOptimistic ,adcmdtext

    if not rsproducts.EOF then
    Response.Write "The Record Already Exist"
    Response.Write vbcrlf
    Response.Write "<a href='addprod.asp'>Add Different ItemProductNumber</a>"

    else





    rsproducts.addnew

    rsproducts("RetailerName") = request.form("txtrn")
    rsproducts("itemproductnumber") = request.form("txtipn")
    rsproducts("itemname") = request.form("txtin")
    rsproducts("ItemPictureFile") = request.form("txtpfn")
    rsproducts("itemdescription") = request.form("txtid")
    rsproducts("itemregularprice") = request.form("txtirp")
    rsproducts("itemsaleprice") = request.form("txtisp")
    rsproducts("itemstockquantity") = request.form("txtisq")
    rsproducts("beginspecial") = Request.form ("txtbs")
    rsproducts("endspecial") = request.form("txtes")
    rsproducts.update
    rsproducts.close
    set rsproducts=nothing
    set conn=nothing

    end if
    --------------------

    Please Help..




    Adeel Ahmed

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    Hi adeelahmed

    the cursor type you are using for you recordset is wrong, your using adOpenStatic, which means the data cannot change. change it to adOpenDynamic and it should sort out your problem

    hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80

    still giving the same error

    Thanx

    but it still giving the same error



    Adeel Ahmed

  4. #4
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Hmm... not sure what your trying to do here:

    Code:
    db=Server.MapPath("MyStore.mdb") 
    
    Provider=MSDASQL & "Mode = Read|Write" & "DBQ=" & db & ";Driver={Microsoft Access Driver (*.mdb)}" & "DSN='MYSTORE' " & "UserCommitSync='Yes' " 
    set conn=server.createobject("adodb.connection") 
    
    conn.open session("dblog")
    1. Where is this session variable defined and what is it defined as

    2. I don't see a connection string (unless that's what the session veriable is and then, what is the stuff above? Did you define MSDASQL as a constant? The above code looks to be trying to use OLEDB *AND* ODBC. Providers are OLEDB providers. Drivers are ODBC drivers.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Location
    Pakistan
    Posts
    80

    ADD/UPDATE PROB.

    Thanx for ur suggestion

    I have defined session in Global.asa as

    session ("dblog")="DSN=MYSTORE"


    But yes ihaven't define MSDASQL as constant.


    plz tell me what should i do to add and update data.




    Adeel Ahmed

  6. #6
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Code:
    Dim cnConn
    Dim strConnect
    Dim rs
    
    strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\yourdatabase.mdb;"
    
    Set cnConn = Server.CreateObject("ADODB.Connection")
    cnConn.ConnectionString = strConnect
    cnConn.Open
    BTW- the concept of an updateable database does not work well with ASP. The reason is that in order to read the records in and allow editing and then write the changes, requires at least two trips to the server. Since the recordset you define when you open for reading is only valid during that page's execution, once the EU modifies and submits changes, essentially another separate connection needs to be opened and used to write the changes to the database. The best solution I think is using update statements to change the data in the database. You have to remember that ASP and the web in general is stateless. Which means you can not open a recordset and use it throughout many pages (You can through the Session object but that adds a whole new set of problems and should be avoided).
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width