sqlserver2000存储过程为:
- SQL code
ALTER procedure p_getmaxid(@tablename varchar(50),@preface varchar(50),@bh varchar(50) output)asbegin trandeclare @i intdeclare @curdate char(8)select @curdate=replace(convert(char(11),getdate(),121),'-','')update tablemax with(rowlock) set @i=case when [email protected] then maxid+1 else 1 end, currentdate = @curdate,@bh= [email protected]+right(power(10,len)[email protected],len),[email protected] where preface = @preface and [email protected] commit tran
pb11.5中一个按钮中的调用为:
- C# code
string bh,tablename,prefacetablename="bloodapp"preface="app"DECLARE pgetmaxid PROCEDURE FOR p_getmaxid @tablename=:tablename,@preface=:preface,@bh=:bh outputusing sqlca;execute pgetmaxid;if sqlca.sqlcode<>0 then close pgetmaxid; return else FETCH pgetmaxid INTO :bh; if sqlca.sqlcode<>0 then close pgetmaxid; return end ifend if
报错为:Database C0038:SQLSTATE=22005[ODBC SQL Server Driver]对于造型说明无效的字符串。
试了好多次都不行,另外,通过DW调用存储过程时,为什么只要是带参数的存储过程都报错。
------解决方案--------------------
ODBC连接数据库是有这个问题,我也遇到,没法搞定。
就只能改成oledb连接
------解决方案--------------------
建议楼主直接用sql server专用接口连接数据库.