PC Review


Reply
Thread Tools Rate Thread

Accessing a Stored Procedure

 
 
Chad
Guest
Posts: n/a
 
      14th Sep 2008
Hi All,

I am just starting to get into Access and Excel. I have worked with a
couple of access databases, but I am now working with an access database
that uses stored procedures and I am stuck.

I was using Microsoft Query to get my data, but it doesn't seem to work with
stored procedures. Could someone lead me in the right direction to connect
to the DB and then access a stored procedure.

Thanks,
Chad


 
Reply With Quote
 
 
 
 
Chad
Guest
Posts: n/a
 
      14th Sep 2008
Looking at other samples, they all seem to start out like:

Dim c As adodb.Connection
Set c = New adodb.Connection

But I get an error saying "user defined type not defined" on the first line

"Chad" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi All,
>
> I am just starting to get into Access and Excel. I have worked with a
> couple of access databases, but I am now working with an access database
> that uses stored procedures and I am stuck.
>
> I was using Microsoft Query to get my data, but it doesn't seem to work
> with stored procedures. Could someone lead me in the right direction to
> connect to the DB and then access a stored procedure.
>
> Thanks,
> Chad
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      14th Sep 2008
Yu need to set a reference in the VBIDE (Tools>references) to Microsoft
ActiveX Data Objects 2.n Library

--
__________________________________
HTH

Bob

"Chad" <(E-Mail Removed)> wrote in message
news:uJ$(E-Mail Removed)...
> Looking at other samples, they all seem to start out like:
>
> Dim c As adodb.Connection
> Set c = New adodb.Connection
>
> But I get an error saying "user defined type not defined" on the first
> line
>
> "Chad" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Hi All,
>>
>> I am just starting to get into Access and Excel. I have worked with a
>> couple of access databases, but I am now working with an access database
>> that uses stored procedures and I am stuck.
>>
>> I was using Microsoft Query to get my data, but it doesn't seem to work
>> with stored procedures. Could someone lead me in the right direction to
>> connect to the DB and then access a stored procedure.
>>
>> Thanks,
>> Chad
>>

>
>



 
Reply With Quote
 
Chad
Guest
Posts: n/a
 
      14th Sep 2008
Thanks Bob,

It appears I am getting in way over my head. But lets keep going anyways.

So I got this part

Dim c As adodb.Connection
Set c = New adodb.Connection

So now I need to open it I am guessing. But I don't know how. It is an
Access 2000 database with stored procedures in it. I hope this helps. In
the database connection menu, it says:
1. MP_SAP
2. Use WinNT integrated security
3. Select the database = MineOperations

When I view the stored porcedure the name is Chad (dbo)

Could you please point me in the right direction again.

Thanks
Chad



"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Yu need to set a reference in the VBIDE (Tools>references) to Microsoft
> ActiveX Data Objects 2.n Library
>
> --
> __________________________________
> HTH
>
> Bob
>
> "Chad" <(E-Mail Removed)> wrote in message
> news:uJ$(E-Mail Removed)...
>> Looking at other samples, they all seem to start out like:
>>
>> Dim c As adodb.Connection
>> Set c = New adodb.Connection
>>
>> But I get an error saying "user defined type not defined" on the first
>> line
>>
>> "Chad" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Hi All,
>>>
>>> I am just starting to get into Access and Excel. I have worked with a
>>> couple of access databases, but I am now working with an access database
>>> that uses stored procedures and I am stuck.
>>>
>>> I was using Microsoft Query to get my data, but it doesn't seem to work
>>> with stored procedures. Could someone lead me in the right direction to
>>> connect to the DB and then access a stored procedure.
>>>
>>> Thanks,
>>> Chad
>>>

>>
>>

>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      15th Sep 2008
Chad,

This is some pure VBA to access an Access SP, adapt for your query


Dim c As ADODB.Connection
Dim RS As ADODB.Recordset

Set c = New ADODB.Connection

c.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "C:\bob.mdb"

Set cmd = CreateObject("ADODB.Command")
Set cmd.ActiveConnection = c

cmd.CommandText = "Chad"
cmd.CommandType = adcmdStoredProc

Set RS = CreateObject("ADODB.Recordset")
RS.Open cmd

Do Until RS.EOF
Debug.Print RS(0), RS(1), RS(2)
RS.MoveNext
Loop

Set RS = Nothing
Set cmd = Nothing
Set c = Nothing


--
__________________________________
HTH

Bob

"Chad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Bob,
>
> It appears I am getting in way over my head. But lets keep going anyways.
>
> So I got this part
>
> Dim c As adodb.Connection
> Set c = New adodb.Connection
>
> So now I need to open it I am guessing. But I don't know how. It is an
> Access 2000 database with stored procedures in it. I hope this helps. In
> the database connection menu, it says:
> 1. MP_SAP
> 2. Use WinNT integrated security
> 3. Select the database = MineOperations
>
> When I view the stored porcedure the name is Chad (dbo)
>
> Could you please point me in the right direction again.
>
> Thanks
> Chad
>
>
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Yu need to set a reference in the VBIDE (Tools>references) to Microsoft
>> ActiveX Data Objects 2.n Library
>>
>> --
>> __________________________________
>> HTH
>>
>> Bob
>>
>> "Chad" <(E-Mail Removed)> wrote in message
>> news:uJ$(E-Mail Removed)...
>>> Looking at other samples, they all seem to start out like:
>>>
>>> Dim c As adodb.Connection
>>> Set c = New adodb.Connection
>>>
>>> But I get an error saying "user defined type not defined" on the first
>>> line
>>>
>>> "Chad" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Hi All,
>>>>
>>>> I am just starting to get into Access and Excel. I have worked with a
>>>> couple of access databases, but I am now working with an access
>>>> database that uses stored procedures and I am stuck.
>>>>
>>>> I was using Microsoft Query to get my data, but it doesn't seem to work
>>>> with stored procedures. Could someone lead me in the right direction to
>>>> connect to the DB and then access a stored procedure.
>>>>
>>>> Thanks,
>>>> Chad
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Chad
Guest
Posts: n/a
 
      15th Sep 2008
My database isn't a *.mdb. It's a *.adp.
I get an unrecognized database format error

I do have a ODBC Data Source linked to it though.


"Bob Phillips" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Chad,
>
> This is some pure VBA to access an Access SP, adapt for your query
>
>
> Dim c As ADODB.Connection
> Dim RS As ADODB.Recordset
>
> Set c = New ADODB.Connection
>
> c.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
> "Data Source=" & "C:\bob.mdb"
>
> Set cmd = CreateObject("ADODB.Command")
> Set cmd.ActiveConnection = c
>
> cmd.CommandText = "Chad"
> cmd.CommandType = adcmdStoredProc
>
> Set RS = CreateObject("ADODB.Recordset")
> RS.Open cmd
>
> Do Until RS.EOF
> Debug.Print RS(0), RS(1), RS(2)
> RS.MoveNext
> Loop
>
> Set RS = Nothing
> Set cmd = Nothing
> Set c = Nothing
>
>
> --
> __________________________________
> HTH
>
> Bob
>
> "Chad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Thanks Bob,
>>
>> It appears I am getting in way over my head. But lets keep going
>> anyways.
>>
>> So I got this part
>>
>> Dim c As adodb.Connection
>> Set c = New adodb.Connection
>>
>> So now I need to open it I am guessing. But I don't know how. It is an
>> Access 2000 database with stored procedures in it. I hope this helps.
>> In the database connection menu, it says:
>> 1. MP_SAP
>> 2. Use WinNT integrated security
>> 3. Select the database = MineOperations
>>
>> When I view the stored porcedure the name is Chad (dbo)
>>
>> Could you please point me in the right direction again.
>>
>> Thanks
>> Chad
>>
>>
>>
>> "Bob Phillips" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Yu need to set a reference in the VBIDE (Tools>references) to Microsoft
>>> ActiveX Data Objects 2.n Library
>>>
>>> --
>>> __________________________________
>>> HTH
>>>
>>> Bob
>>>
>>> "Chad" <(E-Mail Removed)> wrote in message
>>> news:uJ$(E-Mail Removed)...
>>>> Looking at other samples, they all seem to start out like:
>>>>
>>>> Dim c As adodb.Connection
>>>> Set c = New adodb.Connection
>>>>
>>>> But I get an error saying "user defined type not defined" on the first
>>>> line
>>>>
>>>> "Chad" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>>> Hi All,
>>>>>
>>>>> I am just starting to get into Access and Excel. I have worked with a
>>>>> couple of access databases, but I am now working with an access
>>>>> database that uses stored procedures and I am stuck.
>>>>>
>>>>> I was using Microsoft Query to get my data, but it doesn't seem to
>>>>> work with stored procedures. Could someone lead me in the right
>>>>> direction to connect to the DB and then access a stored procedure.
>>>>>
>>>>> Thanks,
>>>>> Chad
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      15th Sep 2008
What is adp, I don't think I have come across that before? But presumably if
it has stored procedures you can set up a connection, with a different
connection string to that that I gave you and run the code?

--
__________________________________
HTH

Bob

"Chad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> My database isn't a *.mdb. It's a *.adp.
> I get an unrecognized database format error
>
> I do have a ODBC Data Source linked to it though.
>
>
> "Bob Phillips" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Chad,
>>
>> This is some pure VBA to access an Access SP, adapt for your query
>>
>>
>> Dim c As ADODB.Connection
>> Dim RS As ADODB.Recordset
>>
>> Set c = New ADODB.Connection
>>
>> c.Open = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>> "Data Source=" & "C:\bob.mdb"
>>
>> Set cmd = CreateObject("ADODB.Command")
>> Set cmd.ActiveConnection = c
>>
>> cmd.CommandText = "Chad"
>> cmd.CommandType = adcmdStoredProc
>>
>> Set RS = CreateObject("ADODB.Recordset")
>> RS.Open cmd
>>
>> Do Until RS.EOF
>> Debug.Print RS(0), RS(1), RS(2)
>> RS.MoveNext
>> Loop
>>
>> Set RS = Nothing
>> Set cmd = Nothing
>> Set c = Nothing
>>
>>
>> --
>> __________________________________
>> HTH
>>
>> Bob
>>
>> "Chad" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Thanks Bob,
>>>
>>> It appears I am getting in way over my head. But lets keep going
>>> anyways.
>>>
>>> So I got this part
>>>
>>> Dim c As adodb.Connection
>>> Set c = New adodb.Connection
>>>
>>> So now I need to open it I am guessing. But I don't know how. It is an
>>> Access 2000 database with stored procedures in it. I hope this helps.
>>> In the database connection menu, it says:
>>> 1. MP_SAP
>>> 2. Use WinNT integrated security
>>> 3. Select the database = MineOperations
>>>
>>> When I view the stored porcedure the name is Chad (dbo)
>>>
>>> Could you please point me in the right direction again.
>>>
>>> Thanks
>>> Chad
>>>
>>>
>>>
>>> "Bob Phillips" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Yu need to set a reference in the VBIDE (Tools>references) to Microsoft
>>>> ActiveX Data Objects 2.n Library
>>>>
>>>> --
>>>> __________________________________
>>>> HTH
>>>>
>>>> Bob
>>>>
>>>> "Chad" <(E-Mail Removed)> wrote in message
>>>> news:uJ$(E-Mail Removed)...
>>>>> Looking at other samples, they all seem to start out like:
>>>>>
>>>>> Dim c As adodb.Connection
>>>>> Set c = New adodb.Connection
>>>>>
>>>>> But I get an error saying "user defined type not defined" on the first
>>>>> line
>>>>>
>>>>> "Chad" <(E-Mail Removed)> wrote in message
>>>>> news:%(E-Mail Removed)...
>>>>>> Hi All,
>>>>>>
>>>>>> I am just starting to get into Access and Excel. I have worked with
>>>>>> a couple of access databases, but I am now working with an access
>>>>>> database that uses stored procedures and I am stuck.
>>>>>>
>>>>>> I was using Microsoft Query to get my data, but it doesn't seem to
>>>>>> work with stored procedures. Could someone lead me in the right
>>>>>> direction to connect to the DB and then access a stored procedure.
>>>>>>
>>>>>> Thanks,
>>>>>> Chad
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Stored Procedure via VBA Patrick Pohlmann Microsoft Access ADP SQL Server 5 10th Feb 2010 02:25 AM
Accessing SQL Server Stored Procedure from VB.NET =?Utf-8?B?Y3Jpc3A5OQ==?= Microsoft Dot NET 1 28th Jan 2005 12:15 AM
Accessing SQL Server Stored Procedure from Access =?Utf-8?B?SmFjaw==?= Microsoft Access Form Coding 1 26th Aug 2004 04:46 PM
Accessing RETURN values from a Stored Procedure peteZ Microsoft ADO .NET 1 1st Sep 2003 05:42 AM
accessing multiple recordsets from a stored procedure Dr. Killer D. Goat The Man Eater Microsoft Dot NET 0 26th Aug 2003 07:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:46 PM.