Bonjour,
Après avoir fait un tour dans la FAQ et avoir appliqué et adapté le code fourni, j'ai un problème lors de l'exécution de ma store proc. Quelqu'un a-t-il déjà rencontré ce problème ?
Objectif de la stored proc : faire un Truncate d'une table dont le nom est passé en paramètre.
Environnement : un fichier mdb qui utiliser une base SQL ; j'ai besoin de faire un truncate d'une table à la place d'un delete * car la table contenant plus de 2 millions de lignes, j'ai un time out qui survient.
Code Stored Proc
Appel de ma procédure dans Access 2003 :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 ALTER PROCEDURE [dbo].[TruncateTable] -- Add the parameters for the stored procedure here @strTableName varchar(255) AS SET NOCOUNT ON BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. TRUNCATE TABLE [dbo].[@strTableName] END
Erreur retournée au niveau de la ligne Cmd.Execute :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 Sub TruncateTable() Dim Cmd As ADODB.Command Dim conConnection As ADODB.Connection Dim strConnection As String Dim Prm1 As ADODB.Parameter Set conConnection = New ADODB.Connection strConnection = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Toto;Data Source=VM-SQL" conConnection.Open strConnection Set Cmd = New ADODB.Command Cmd.ActiveConnection = strConnection Cmd.CommandType = adCmdStoredProc Cmd.CommandText = "TruncateTable" Set Prm1 = Cmd.CreateParameter("@strTableName", adVarChar, adParamInput, 100, "tblToto") Cmd.Parameters.Append Prm1 Prm1.Value = "tblToto" Cmd.Execute Set Cmd = Nothing End Sub
Run-time error '-2147217865(80040e37)': Cannot find the object "@strTableName" because it does not exist or you do not have permissions....
D'avance merci....
Partager