你好:
紧急求助,如何从SQL数据库中,将表中记录插入到ACCESS数据库表中?
SQL数据库在服务器上,本地只有SQL客户端,我在 ODBC 中分别建了一个数据源。
我根据大侠会的贴子写的这段代码:
CommandText:='insert into Local_Msr_DB (ypid,inout,pact_id,ick_id,ch,cunit_id,'+
'cunit_name,gunit_id,gunit_name,Breed_id,Breed_name,total,spare,'+
'ccfw,ypyid,cname,ifsampl,multi) '+
'select ypid,inout,pact_id,ick_id,ch,cunit_id,'+
'cunit_name,gunit_id,gunit_name,Breed_id,Breed_name,total,spare,'+
'ccfw,ypyid,cname,ifsampl,multi '+
' from Msr_PreBasic in ''''[ODBC;DRIVER=SQL Server;SERVER=WIN\TALENT_SQL;UID=sa;PWD=netmanager;DATABASE=Erp_Basic] '+
' where cancel is null and ypid not in(select ypid from Local_Msr_DB where cancel is null)';
CommandType:=cmdText;
Execute;
执行时还是会出错:
Project MeasureCarWeigh.exe raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver][SQL Server]在关键字 'in' 附近有语法错误。'. Process stopped. Use Step or Run to continue.
请问是哪里出错了。
谢谢
紧急求助,如何从SQL数据库中,将表中记录插入到ACCESS数据库表中?
SQL数据库在服务器上,本地只有SQL客户端,我在 ODBC 中分别建了一个数据源。
我根据大侠会的贴子写的这段代码:
CommandText:='insert into Local_Msr_DB (ypid,inout,pact_id,ick_id,ch,cunit_id,'+
'cunit_name,gunit_id,gunit_name,Breed_id,Breed_name,total,spare,'+
'ccfw,ypyid,cname,ifsampl,multi) '+
'select ypid,inout,pact_id,ick_id,ch,cunit_id,'+
'cunit_name,gunit_id,gunit_name,Breed_id,Breed_name,total,spare,'+
'ccfw,ypyid,cname,ifsampl,multi '+
' from Msr_PreBasic in ''''[ODBC;DRIVER=SQL Server;SERVER=WIN\TALENT_SQL;UID=sa;PWD=netmanager;DATABASE=Erp_Basic] '+
' where cancel is null and ypid not in(select ypid from Local_Msr_DB where cancel is null)';
CommandType:=cmdText;
Execute;
执行时还是会出错:
Project MeasureCarWeigh.exe raised exception class EOleException with message '[Microsoft][ODBC SQL Server Driver][SQL Server]在关键字 'in' 附近有语法错误。'. Process stopped. Use Step or Run to continue.
请问是哪里出错了。
谢谢
Server;SERVER=WIN\TALENT_SQL;UID=sa;PWD=netmanager;DATABASE=Erp_Basic] '后面本来是否应有双引号与前面对应
我试了,还是会出现这样的问题。
把[ODBC;DRIVER=SQL Server;SERVER=WIN\TALENT_SQL;UID=sa;PWD=netmanager;DATABASE=Erp_Basic] 换成我在本地机子上建立的odbc数据源怎么写。