¤ Stored procedure does not allow addition of a record with rs.addrecord.
¤ Database is on SQL SERVER EXPRESS.
¤ An .adp ACCESS 2007 application is connected to it (easier to create/modify objects).
¤ Stored procedure was created with the .adp application.
¤ Any one can help? Thanks JL.
¤ Here is a piece of code that shows the same problem:

' Type 'Paramètre' pour procédures paramétrisées (stored procedure).
Public Type spParams
prmNom As String
prmType As DataTypeEnum
prmValeur As Variant
End Type

Public Sub Test()

Dim prm(0) As spParams
Dim rsGroupes As ADODB.Recordset

With prm(0)
.prmNom = "@LaDateD"
.prmType = ADODB.adInteger
.prmValeur = 20080626
End With ' prm(0)
Set rsGroupes = rsOpen("spGroupesLaDateD", prm)
With rsGroupes
If .RecordCount < 1 Then
!IDEmploye = 1
!ClientID = 8
!DateEntrée = Date
!Description = "Arseneau & amies 2"
!Nbre = 4
!DateD = 20080625
!DateDébut = #6/25/2008#
!DateFin = !DateDébut
End If
End With

End Sub

Public Function rsOpen( _
txtSPName As String, _
prm() As spParams _
) As ADODB.Recordset
On Error GoTo Erreur

Dim I As Long
Dim strErr As String

Dim cmdObj As New ADODB.Command
Dim prmObj As ADODB.Parameter

' Définir l'objet 'ADODB.Command'.
Set cmdObj = New ADODB.Command
With cmdObj
.ActiveConnection = "Provider=SQLOLEDB.1;Password=MyPassword ;Persist Security Info=True;User ID=sa ;Initial Catalog=MyDB;Data Source= SUPPORT\SQLExpress"

' Caractériser la commande.
.CommandText = txtSPName
.CommandType = adCmdStoredProc
.CommandTimeout = 15

' Définir le(s) paramètre(s) d'input.
Set prmObj = New ADODB.Parameter
For I = LBound(prm, 1) To UBound(prm, 1)
With prmObj
.Name = prm(I).prmNom
.Type = prm(I).prmType
Select Case prm(I).prmType
Case ADODB.adDate, ADODB.adInteger
.Size = 4
Case ADODB.adVarChar
.Size = Len(prm(I).prmValeur)
Case Else
MsgBox "Type de parametre inconnu: " & prm(I).prmValeur
End Select
.Direction = adParamInput
.Value = prm(I).prmValeur
End With ' prmObj
Next I
.Parameters.Append prmObj

Set rsOpen = New ADODB.Recordset
With rsOpen
Set .Source = cmdObj
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
End With
End With ' cmdObj

Exit Function

MsgBox Err.Description, vbCritical
Resume Done

End Function

¤ Stored procedure (as displayed by <modify>:

ALTER PROCEDURE [dbo].[spGroupesLaDateD](@LaDateD int)
AS SELECT dbo.Groupes.*
FROM dbo.Groupes
WHERE (DateD = @LaDateD)

9 Years
Discussion Span
Last Post by JLCantara

You code is too much to go through.
just explain th e exact problem.

¤ The 1st line tells it all!!!

¤ All you have to do is copy paste the code (unfortunately, the text editor of DaniWeb strips the indentation) and follow it in step mode: you will see, it is cristal clear!!!

¤ Are you familiar with ADODB?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.