Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql - insert doesn't work for numeric value?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP1
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01001142
Message ID:
01001145
Views:
17
>Hi all!
>
>Please check the codes, and help me to find the correct way of doing this, I can't find a solution as I am new to SQL server.
>
>In SQL Table
>DESCRIPTION NVARCHAR (25)
>TNUMBER FLOAT
>
>In FoxPro Form
>cDescription = AllTrim(Thisform.txtDescription.Value) <--- character value
>nTNumber = Thisform.txtTNumber.Value <--- numeric value
>
>=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (DESCRIPTION) VALUES ('&cDescription') " ) <--- this command works and saves the record
>
>=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (TNUMBER) VALUES ('&nTNumber') " ) <--- this command doesn't work
>
>Did I miss something here?

I am supprised that first command works. Never mind, try this:
=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (DESCRIPTION) VALUES ('"+cDescription+"') " )
=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (TNUMBER) VALUES ("+TRANSFORM(nTNumber)+")" )

or
=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (DESCRIPTION) VALUES (?cDescription)" )
=SQLExec(gnConnectionHandle, "INSERT INTO [TRANSFILE].[DBO].[ADJFILE] (TNUMBER) VALUES (?nTNumber)" )
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Reply
Map
View

Click here to load this message in the networking platform