vs2010没有返回结果不知道是出错还是怎么回事,sqlserver返回的是正确的结果
求各位高手赐教
ps:下面是创建存储过程的代码,查询数据库中OpenRoomInfo表中的数据
/*查询所有的开房信息(首页的Grid,带搜索功能)*/
create proc GetOpenRoomInfoAll(@message varchar(50))
as
if (@message = '')
begin
select a.OpenRoomId,b.Number,c.TypeName,c.TypePrice,a.OpenTime,a.PlanDays,a.GuestMoney,a.GuestId,
a.GuestName,a.GuestPhone,a.Re from OpenRoomInfo as a,Room as b,RoomType as c
where a.RoomId = b.RoomId and b.TypeId = c.TypeId
end
else
begin
select a.OpenRoomId,b.Number,c.TypeName,c.TypePrice,a.OpenTime,a.GuestMoney,a.GuestId,a.GuestName,
a.GuestPhone,a.Re from OpenRoomInfo as a,Room as b,RoomType as c where a.RoomId = b.RoomId and
b.TypeId = c.TypeId and (b.Number like @message+'%' or c.TypeName like @message+'%'
or a.GuestId like @message+'%' or a.GuestName like @message+'%'
or a.GuestPhone like @message+'%' or a.Re like @message+'%')
end
go
求各位高手赐教
ps:下面是创建存储过程的代码,查询数据库中OpenRoomInfo表中的数据
/*查询所有的开房信息(首页的Grid,带搜索功能)*/
create proc GetOpenRoomInfoAll(@message varchar(50))
as
if (@message = '')
begin
select a.OpenRoomId,b.Number,c.TypeName,c.TypePrice,a.OpenTime,a.PlanDays,a.GuestMoney,a.GuestId,
a.GuestName,a.GuestPhone,a.Re from OpenRoomInfo as a,Room as b,RoomType as c
where a.RoomId = b.RoomId and b.TypeId = c.TypeId
end
else
begin
select a.OpenRoomId,b.Number,c.TypeName,c.TypePrice,a.OpenTime,a.GuestMoney,a.GuestId,a.GuestName,
a.GuestPhone,a.Re from OpenRoomInfo as a,Room as b,RoomType as c where a.RoomId = b.RoomId and
b.TypeId = c.TypeId and (b.Number like @message+'%' or c.TypeName like @message+'%'
or a.GuestId like @message+'%' or a.GuestName like @message+'%'
or a.GuestPhone like @message+'%' or a.Re like @message+'%')
end
go
@message传入的内容是否存在编码问题?测试编码问题你可以使用英文测试
你确保你程序调用的数据库跟你测试的是一个,并且存储过程代码是一样的另外,传参数最好Trim()下空格
你没有看到调试器抛出的异常么,如果调试器抛出异常,看它的InnerException属性,可以看到Sql Server返回的异常提示。如果调试器没有异常,那么要看看你自己的的代码了,例如有没有画蛇添足的try...catch使得你根本丧失了调试、测试的能力。这时候删除try...catch就行了。sql server语句中根本没有go这种东西。当你在sql server的查询分析器中打入go,那不过是让查询分析器分割sql语句用的,查询分析器也不会把这个“go”发送给sql server系统去执行的。所以你在.net程序中发送sql语句给sql server服务器进程时,也不应该包括“go”。
(sda是一个DataAdapter对象)
数据库连接正常,实验Insert存储过程正常,这个Select存储过程却不行