Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Error with VFP datatypes and SQL Server
Message
 
 
À
20/02/2002 15:58:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00622742
Message ID:
00622863
Vues:
34
This message has been marked as the solution to the initial question of the thread.
The Exec T-SQL command is requirede to execute stored procedure.
? SQLEXEC(lnConn,[Exec sp_TestInsert ?lcFirst, ?lcLast, ?lnNumber, ?lnDecNumber, ?ltDate])
>Hi Sergey,
>
>I did as suggested, and yes, something changed, because now I get the error
>'Incorrect syntax near sp_TestInsert', so something's still amiss.
>Got any ideas?
>
>
>>You are passing the names of variables as parameters not there values. Prefix them with "?" character to make them SqlExec parameters and they will be substituted by there values.
? SQLEXEC(lnHandle,[sp_TestInsert ?lcFirst, ?lcLast, ?lnNumber, ?lnDecNumber, ?ltDate])
>>
>>>In this little procedure I've encountered the following:
>>>
>>>
>>>CREATE PROCEDURE [dbo].[sp_TestInsert]
>>>@PFirst CHAR(10),
>>>@PLast CHAR(10),
>>>@PNumber INT,
>>>@PDecimal DECIMAL(18,3),
>>>@PDate DATETIME
>>> AS
>>
>>>INSERT INTO TEST (Firstname,LastName,Number,DecNumber,DateTest)
>>VALUES (@Pfirst,@PLast,@PNumber,@PDecimal,@PDate)
>>>
>>>
>>>When called from VFP this way:
>>>
>>>lcLast="Last"
>>>lcFirst="First"
>>>lnNumber=1
>>>lnDecNumber=1.1
>>>ltDate=DATETIME()
>>>
>>>? SQLEXEC(lnHandle,[sp_TestInsert lcFirst,lcLast,lnNumber,lnDecNumber,ltDate])
>>>
>>>
>>>The insert fails with an 'Error converting datatype nvarchar to int' or an 'Error converting datatype nvarchar to datetime' error respectively.
>>>
>>>? SQLEXEC(lnHandle,[sp_TestInsert lcFirst,lcLast,1,1.1,'2002-02-20 19:21:36'])
>>>on the other hand makes it through.
>>>
>>>I have not (knowingly) passed nvarchar datatypes to SQL Server, so if anybody knows what's going on and how to solve this, I'd be reaslly grateful.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform