include <stdio.h>
#include <string.h>
#include <stdlib.h>
EXEC SQL DECLARE dblinkname1 DATABASE;
EXEC SQL INCLUDE SQLCA;
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[50],password[20],dbname[20];
EXEC SQL END DECLARE SECTION;
strcpy((char *)username.arr,"test");
username.len = strlen((char *)username.arr);
strcpy((char *)password.arr,"test");
password.len = strlen((char *)password.arr);
strcpy((char *)dbname.arr,"192.168.3.38"); // tagA 请教此处
dbname.len = strlen((char *)dbname.arr);
EXEC SQL CONNECT :username IDENTIFIED BY :password AT dblinkname1 USING :dbname; // tagB
if (sqlca.sqlcode)
{
printf("fail to connect!\n");
return 1;
}
printf("connect to db successfully\n");
EXEC SQL AT dblinkname1 COMMIT WORK RELEASE;
return 0;
}
用Pro*C边本机的Oracle时, tagB处把"using :dbname"去掉就可以了
现在要连接LAN中的另一台机器, IP=92.168.3.38, oracle数据库名=dztl.
请教高手tagA处应该怎么写
------解决方案--------------------
使用net configuration assistant配置连接串,测试成功后引用。
server应该是连接串名。
------解决方案--------------------
用netca配置本地服务名,USING :本地服务名;就可以了