Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failure to call stored procedure from SQL Server

Status
Not open for further replies.

pthalacker

Programmer
Aug 30, 2004
150
I am converting a bunch of VFP code to SQL Server stored procedures so they can be called from Asp.Net. I can call the stored procedure in the Enterprise Manager and get the appropriate result set. I have a valid connection handle to the database containing the stored procedure, but when run the following code:
Code:
lcSql = [Execute GetAcctBalance '20030509AG', '12/31/2006']
lnResult = SQLExec(oSpi.hConn, m.lcSql, 'csrBalance')
I get an ODBC error: Could not find stored procedure 'GetAcctBalance'

Can you assist me in troubleshooting this?

pamela
 
Are you sure your connection is open the right DataBase? What happens if you call SP that way:
Code:
lcSql = [Execute DataBaseNameHere.dbo.GetAcctBalance '20030509AG', '12/31/2006']
lnResult = SQLExec(oSpi.hConn, m.lcSql, 'csrBalance')

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Are you sure your connection is open the right DataBase?
Yes. I am using the same connection string that I have been using to successfully connect to 4 other databases on the same server. Just change the database name.

This works:
Code:
lcSQL = [Select * from Sysobjects]
This gets me the same error:
Code:
lcSql = [Execute DataBaseNameHere.dbo.GetAcctBalance '20030509AG', '12/31/2006']

pamela
 
Then you are created that SP in some other DataBase. Try:
Code:
lcSql = [Execute master.dbo.GetAcctBalance '20030509AG', '12/31/2006']

Run this in QA:
Code:
sp_MSForEachDB 'SELECT ''?'' AS DBase WHERE object_id(''?..GetAcctBalance'') IS NOT NULL'
and you will get the list of the DataBases where that SP is defined

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Actually it wasn't the wrong database. It was the wrong server.

pamela
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top