标题:帮帮忙!
取消只看楼主
潇湘夜雨
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-5-1
 问题点数:0 回复次数:0 
帮帮忙!
#include <stdio.h>
以下的嵌入SQL语句的C语言程序在用NSQLPREP.EXE预编译的时候总是出现如下提示,不知那位高手能为我答疑解惑,该怎么修改?这里先行谢过

C:\Program Files\Microsoft SQL Server\MSSQL\Binn>NSQLPREP Ex.sqc
Microsoft (R) Embedded SQL for C Pre-Compiler. Version 8.00.194.
Copyright (c) Microsoft Corp 1993-1998. All rights reserved.

Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Ex.sqc
Warning: Ex.sqc, line 25: syntax error.
EXEC SQL DECLARE SX CURSOR FOR


SQLPREP: SQL Compile Error at line 45
  UPDATE Student SET Sage=@p1      where CURRENT OF SX

Error code: -19946
Cursor SX not declared


SQLPREP: SQL Compile Error at line 50
  CLOSE SX

Error code: -19946
Cursor SX not declared
Warning: Ex.sqc, line 53: syntax error.
}

C:\Program Files\Microsoft SQL Server\MSSQL\Binn>
程序如下:
EXEC SQL BEGIN DECLARE SECTION;

char deptname[20];
char HSno[9];
char HSname[20];
char HSsex[2];
int  HSage;
int  NEWAGE;

EXEC SQL END DECLARE SECTION;

long SQLCODE;

EXEC SQL INCLUDE sqlca;

int main()
{
 int count=0;
 char yn;
 printf("Please choose the department name(CS/MA/IS): ");
 scanf("%s",&deptname);
 EXEC SQL CONNECT TO COMPUTER;
 EXEC SQL DECLARE SX CURSOR FOR
     select Sno,Sname,Ssex,Sage
     from Student
     where SDept=:deptname;
 EXEC SQL OPEN SX;
 for( ; ; ){
     EXEC SQL FETCH SX INTO :HSno,:HSname,:HSsex,:HSage;
 if(sqlca.sqlcode != 0)
     break;
 if(count++ = 0)
     printf("\n%-10s%-20s%-10s%-10s\n","Sno","Sname","Ssex","Sage");
     printf("%-10s%-20s%-10s%-10s\n",HSno,HSname,HSsex,HSage);
 
 printf("UPDATE AGE(y/n)?");
 do{
     scanf("%c",&yn);
 }while(yn!='N'&&yn!='n'&&yn!='Y'&&yn!='y');
 if(yn == 'y' || yn == 'Y'){
     printf("INPUT NEW AGE:");
     scanf("%d",&NEWAGE);
     EXEC SQL UPDATE Student
         SET Sage=:NEWAGE
         where CURRENT OF SX;
 }
 }
 EXEC SQL CLOSE SX;
 EXEC SQL COMMIT WORK;
 EXEC SQL DISCONNECT COMPUTER;
}
搜索更多相关主题的帖子: Microsoft include C语言 
2007-11-29 23:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-189416-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050461 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved