| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 882 人关注过本帖
标题:帮帮忙!
只看楼主 加入收藏
潇湘夜雨
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-5-1
收藏
 问题点数:0 回复次数:1 
帮帮忙!
#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
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
游标那块错了..
对嵌入式的SQL不是很了解..
看看是否游标声明时没有指定是否为可更新的游标..

我的msn: myfend@
2007-11-30 09:49
快速回复:帮帮忙!
数据加载中...
 
   



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

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