Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ODBC -- inserting records into SQL Server
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00998178
Message ID:
00998180
Views:
21
This message has been marked as the solution to the initial question of the thread.
See Re: Remote (SQL-Server) Query Message #875085 for the proper way to handle ODBC errors. To make your INSERT work, prefix variable with '?' to make them SPT parameters.
pn_sqle = SQLExec(pn1, "INSERT vz_notes (dbacct, dataline) VALUES(?pc_acct, ?pc_data)")
>I am trying to insert records into SQL Server from Fox via ODBC, and this should be a simple task (I've been selecting data without problem), but I'm having no luck so far.
>
>My coding (simplified) is:
>	CREATE DATABASE test
>	CREATE CONNECTION MyODBC 
DATASOURCE "purges_tmp" 
USERID "taskadmin" PASSWORD "taskadmin"
>	pn1 = SQLConnect( pc_dsrc, pc_uid, pc_uid )
>	DISPLAY CONNECTIONS
>	SELECT dlvm
>	pc_acct = acct_no
>	pc_data = dataline
>	pn_sqle = SQLExec(pn1, "INSERT vz_notes (dbacct, dataline) VALUES(pc_acct, pc_data)")
>	=SQLDISCONNECT( pn1)
>	DELETE CONNECTION MyODBC
>I am consistently getting a return of 1 for the SQLConnect, and (-1) on the SQLExec. Is my syntax wrong, or could the SQL Server table be locked to updates? What am I missing here?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform