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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot execute a DAO Code accessing an SQL 2000 Server

Status
Not open for further replies.

maupiti

Programmer
Oct 27, 2003
240
US
Run-Time Error '3146'
ODBC - Call Failed
Error at statement cnn.Execute strSQL

//////////////////////////////////

Private Sub DAO_SP()
Dim wrk As DAO.Workspace
Dim cnn As DAO.Connection
Dim qdf As DAO.QueryDef
Dim strConnect As String, strSQL As String

Set wrk = DBEngine.CreateWorkspace("NewODBCWrk", "admin", "", dbUseODBC)
strConnect = "ODBC;DSN=WIN-2000-Server;DATABASE=Pubs;UID=linh;PWD=password;"
Set cnn = wrk.OpenConnection("", dvDrivernoprompt, False, strConnect)
strSQL = "CREATE PROCEDURE UpdateAuthors @state Char(2) AS " _
& "UPDATE Authors " _
& "SET state = 'FL'" _
& "WHERE state = @state"
cnn.Execute strSQL
Set qdf = cnn.CreateQueryDef("qry", "{ call UpdateAuthors(?) }")
qdf.Parameters(0).Value = "NC"
qdf.Execute
cnn.Close
wrk.Close
End Sub
 
I want to do this for learning purposes. When I see that it work, I move on to ADO and other method. Also, I have databases that all have DAO code. Running existing DAO code on SQL server saves time, though of cource it is not as effecient as ADO.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top