|
Home > Archive > FoxPro database connector > September 2005 > Insert into sqlserver
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Insert into sqlserver
|
|
| dfranklyn 2005-09-01, 11:25 am |
| I am trying to insert a record into sqlser 2000/2005. I can query and update
existing records but not insert. I don't get an error on the command but
nothing is posted to the table. My code looks like this
<begin code>
#DEFINE SQL_NAME "devsql"
#DEFINE SQL_UID ""
#DEFINE SQL_PWD ""
*~~~~~~~~~~~
LOCAL lcSQLConnStr, ;
lnSQLConnHandle, ;
lnSQLExecSuccess
lcSQLConnStr = "DRIVER={SQL Server};SERVER=" + SQL_NAME + ;
" ;DATABASE=MEMBERSHIP
;UID=" + SQL_UID + ";PWD=" + SQL_PWD
lnSQLConnHandle = SQLSTRINGCONNECT(lcS
QLConnStr)
IF lnSQLConnHandle < 1
LOCAL laErrArray[1]
AERROR(laErrArray)
WAIT WINDOW "Unable to connect:" + CHR(13) + laErrArray[3]
RETURN .F.
ENDIF
SET STEP ON
LOCAL inmemnumb as String
inmemnumb = '1234567'
lnconn=SQLCONNECT('d
evsql')
lnSQLExecSuccess = SQLEXEC(lnSQLConnHan
dle, "insert into
newmemb(id,local,pri
_loc,folio,lastname,
f_init);
values('1234567','04
95','0000','T''ALDRI
DGE','L')")
lnSQLExecSuccess = SQLEXEC(lnSQLConnHan
dle, "SELECT * from newmemb where id
= ?inmemnumb ", "RESULTS")
SQLDISCONNECT(lnSQLC
onnHandle)
IF SELECT("RESULTS") > 0
SELECT RESULTS
BROWSE NOWAIT
ENDIF
<end code>
Can anyone tell me why the insert is not working?????
dfw
| |
| Cindy Winegarden 2005-09-01, 8:26 pm |
| Hi DFranklyn,
Usually news clients break up long lines, so it's hard to tell where your
line breaks actually are, it appears that there's a line break in your
Insert statement and none in your Select statement. You've got a line break
in the middle of a quoted string in your Insert statement. You'd be better
off concatenating two shorter strings such as:
lnSQLExecSuccess = ;
SQLEXEC(lnSQLConnHan
dle, ;
"insert into newmemb(id,local,pri
_loc,folio,lastname,
f_init) " + ;
" values('1234567','04
95','0000','T''ALDRI
DGE','L')")
Also, it looks like you're missing a comma between the two single quotes
between T and ALDRIDGE.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy_winegarden@msn
.com www.cindywinegarden.com
Blog: http://spaces.msn.com/members/cindywinegarden
"dfranklyn" < dfranklyn@discussion
s.microsoft.com> wrote in message
news:B4A45916-5821-4911-B750- E16E6CBB0ED8@microso
ft.com...
>I am trying to insert a record into sqlser 2000/2005. I can query and
>update
> existing records but not insert. I don't get an error on the command but
> nothing is posted to the table. My code looks like this
> lnSQLExecSuccess = SQLEXEC(lnSQLConnHan
dle, "insert into
> newmemb(id,local,pri
_loc,folio,lastname,
f_init);
> values('1234567','04
95','0000','T''ALDRI
DGE','L')")
>
> lnSQLExecSuccess = SQLEXEC(lnSQLConnHan
dle, "SELECT * from newmemb where
> id
> = ?inmemnumb ", "RESULTS")
|
|
|
|
|