Mike Eghtebas
asked on
Stored procedure Access front end w/ sql-server backend...
I am looking for vba code (connection and binding to the form, etc) to call spThreeCustFields from Access continuous form and display its content.
Create Proc spThreeCustFields
As
Begin
SELECT [CustomerID]
,[CompanyName]
,[ContactName]
FROM [Northwind].[dbo].[Custome rs]
End
Thank you.
Create Proc spThreeCustFields
As
Begin
SELECT [CustomerID]
,[CompanyName]
,[ContactName]
FROM [Northwind].[dbo].[Custome
End
Thank you.
ASKER
I am getting an error:
Also please check my connection string. To make sure, I have a continuous form with three text boxes bound and named as the three fields (CustomerID, CompanyName, and ContactName) included in the proc.
Private Sub Form_Load()
Dim rst As New ADODB.Record '<--*****Complie error: User-defined type not defined
Dim con As New ADODB.Connection
con.CursorLocation = adUseClient
con.Open "Data Source=.;Initial Catalog=Northwind;Integrated Security=True"
rst.Open "EXEC spThreeCustFields", con
Me.Recordset = rst
End Sub
Also please check my connection string. To make sure, I have a continuous form with three text boxes bound and named as the three fields (CustomerID, CompanyName, and ContactName) included in the proc.
You apparently don't have a reference to the ADO library. As with all other versions of Access, you open the VBA Editor and click Tools - References, then find the ADO library and check the version you want to use (I used 2.7, I believe).
ASKER
I am getting another error at line 6:
Run-time error '-2147217887(80040e21)':
Multiple-step OLE DB operation generated errors, Check each OLE DB status value, if available. No work was done.
con.Open "Data Source=.;Initial Catalog=Northwind;Integrat ed Security=True"
also tried:
con.Open ".;Initial Catalog=Northwind;Integrat ed Security=True"
con.Open "(local);Initial Catalog=Northwind;Integrat ed Security=True"
fyi, I use the following in my c# app and it works fine:
Run-time error '-2147217887(80040e21)':
Multiple-step OLE DB operation generated errors, Check each OLE DB status value, if available. No work was done.
con.Open "Data Source=.;Initial Catalog=Northwind;Integrat
also tried:
con.Open ".;Initial Catalog=Northwind;Integrat
con.Open "(local);Initial Catalog=Northwind;Integrat
fyi, I use the following in my c# app and it works fine:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="csDatabase"
connectionString="Data Source=.;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
The "multistep" error often means something is misspelled, or you're referring to a table incorrectly.
Can you run the SP directly in SQL Server Management Studio?
Can you run the SP directly in SQL Server Management Studio?
ASKER
The stored procedure is tested before in SSMS and it works. This is what I have used in vs 2010 successfully:
connectionString="Data Source=.;Initial Catalog=Northwind;Integrat ed Security=True"
but is the following syntax correct for access?
con.Open ".;Initial Catalog=Northwind;Integrat ed Security=True"
Mike
connectionString="Data Source=.;Initial Catalog=Northwind;Integrat
but is the following syntax correct for access?
con.Open ".;Initial Catalog=Northwind;Integrat
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the link; it looks good.
ASKER
Thank you.
Open in new window