Click here to Skip to main content
15,922,584 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this code to call a Sql Stored procedure From Access
and this is the code

VB
Dim cmd As New ADODB.Command, RSado As New ADODB.Recordset
Dim RSdao As DAO.Recordset, i As Integer
cmd.ActiveConnection = "Server=HP-PC ;database=Bid ;Integrated Security=true ;"
cmd.CommandTimeout = 600
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_addlink"
cmd.Parameters("@path").Value = CurrentDb().Name
Set RSado = cmd.Execute
Set RSdao = CurrentDb.OpenRecordset("tbl1")
Do While Not RSado.EOF
    RSdao.AddNew
    For i = 0 To RSado.Fields.Count - 1
        RSdao(i) = RSado(i)
    Next
    RSdao.Update
    RSado.MoveNext
Loop
RSdao.Close
RSado.Close
cmd.ActiveConnection.Close


and this is the coming error
multiple-step OLEDB operation generated error.check each OLEDB
status value ,if available not work was done
Posted
Updated 10-Feb-11 8:51am
v3

1 solution

Hi,

You're trying to call a stored procedure on SQL Server, right? If that's the case, procedure name sp_addlink doesn't sound familiar. If you're trying to add a linked server you should use sp_addlinkedserver instead, see:
VB
sp_addlinkedserver

[^]
 
Share this answer
 
Comments
Yasser El Shazly 10-Feb-11 15:25pm    
i already Call it in side this Procedure i now change the Connection String
<p>
Dim ConnectionString As String
ConnectionString = "server=localhost;uid=Phil;pwd=ItsASecret;InitialCatalog = MyDb"
cmd.ActiveConnection = ConnectionString
</p>
this is the error
[Microsoft][ODBC Driver Manager]Data source Not Found and no default driver specified
can you help me in doing that..?
Wendelius 10-Feb-11 15:47pm    
Without seeing the actual statements in your procedure it's quite hard to say what's wrong. But based on the error you are most likely trying to use an ODBC driver which is not installed on the SQL Server machine or the DSN does not exist.

If you're creating the linked server in SQL Server stored procedure, take out the call to sp_addlinkedserver and try to run it in the management studio and make modifications to correct the call if it fails.

If you're using DSN's, it's easiest to define it as System DSN so it's visible to all users on the SQL Server machine. If you define it as User DSN, it must be under the same credentials as the SQL Server is running.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900