Results 1 to 3 of 3

Thread: Recordset and stored procs...HELP

  1. #1
    Guest

    Post

    Hi,

    I'm building a VB6 front-end to a Access97 db. In Access I have defined some querys/views and a couple of parameterized querys. The last ones is what I'm interrested in using inside VB. HOW?

    I started out with defining dataenvironment, connection obj. and command obj. This was fine for extracting info, but I was unable to UPDATE the recordsets I got back to the Access db. ANY SUGGESTIONS?

    The reason I tried to use command obj. is that this is the only way I KNOW of using stored procs. inside my Access db.

    To get the UPDATE right after extracting recordsets, I started using recordset obj. But how do I use mye stored procs in Access using recordset obj.?!?! Is it possible, or must I write the SQL-sentence??

    Please help!

    Thomas

  2. #2
    Addicted Member
    Join Date
    Feb 1999
    Location
    Belfast
    Posts
    254

    Post Recordset and stored procs...HELP

    Thomas,
    can you post some of your source and results please. There should be no problem using the parameters collection in VB to send parameters to a query in Access.

    I believe using the command object, with the parameters collection is the correct one.


  3. #3
    Guest

    Post

    Hi again,

    some of the code goes like this:

    'used to pass search-paramenter
    Dim i As Integer

    Set rs = New Recordset
    Set cmdObj = New Command
    i = txtIn.Text 'simple cast to integer


    'initialize command object
    'I tried to set activeConnection using the connection Designer, and I get the same result with this

    With cmdObj
    .ActiveConnection = "DBQ=D:\Prosjekter\Track\track.mdb;DefaultDir=D:\Prosjekter\Track;Driver={Microsoft Access Driver (*.mdb)};DriverId=281;Exclusive=0;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;ReadOnly=0;UID=admin;"
    .CommandType = adCmdStoredProc
    .CommandText = "enOkt"
    .Parameters.Append cmdObj.CreateParameter _
    ("puls",adInteger , adParamInputOutput)
    .Parameters("puls").Value = i
    '.Execute
    End With


    'don't know if these have any effect here...

    rs.CursorType = adOpenDynamic
    rs.LockType = adLockOptimistic

    Set rs = cmdObj.Execute

    'bind to control
    Set txtRes.DataSource = rs
    txtRes.DataField = "dato"





    Ok, so as you can see. I make a command object. Connect this to the source and executes. No problem so far. I get a recordset(s) back, and bind the field "dato" (date) to a textbox. Still no problem.

    Now, I change the value in the textbox with the "dato"-field, and execute a

    rs.update

    I get a message that goes something like this (from Norwegian..hehe):
    "Runtime error 3251. The operation tha was asked for is not supported by the provider" (donno how it goes in English).



    I tried to do the same operation using ONLY a recordset obj. That is, opening a recordset without the use of a command- or connection obj. This turns out fine. The only "problem" is that I have to write the SQL-sentence and send it with the recordset. This sullution would be a "client-side" sullution; not using any querys/stored procs in the db. But I WANT to use the "server-side" sollution, using querys that I have made in the db. (Am I difficult...?!


    thomas

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