写vb.net程序出现的问题,请指教,谢谢!

xmjcwo 2003-10-25 02:42:15
写vb.net程序出现的问题,请指教,谢谢!
出现以下问题求助啊
Dim ds As DataSet
Dim Da As SqlDataAdapter
Dim Dt As DataTable
Dim str As String '查询条件字符串
Dim selectstr As String '选择输出项字符串
。。。。。。。。。。。。。
。。。。。。。。。。。。。
Da = New SqlDataAdapter("Select Selectstr WebCstomer_Info Where sel= Like % sc% ", conn)
ds = New DataSet()
Da.Fill(ds, "WebCstomer_Info")
DataGrid1.DataSource = ds.Tables(0).DefaultView
DataGrid1.Refresh()
DataGrid1.CurrentRowIndex = 0
编译通过,运行查询时出现错误:
处理的“System.Data.SqlClient.SqlException”类型的异常出现在 system.data.dll 中

其他信息:系统错误
为什么会这样请指教!
...全文
33 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
freesnower1001 2003-10-25
  • 打赏
  • 举报
回复
应该是你的SQL语句有错
select 字段名 from 表明 where 选择的条件
这个是固定的格式!

qqwqq 2003-10-25
  • 打赏
  • 举报
回复
Da = New SqlDataAdapter("Select Selectstr WebCstomer_Info Where sel Like % sc% ", conn)

去掉=號
southdoor 2003-10-25
  • 打赏
  • 举报
回复
dim strsql="Select Selectstr WebCstomer_Info Where sel= Like %' & sc & "' % "
单步调试至此,看看strsql是否是你想要的.
Da = New SqlDataAdapter(strsql, conn)
xmjcwo 2003-10-25
  • 打赏
  • 举报
回复
发现了是sql出了问题
Da = New SqlDataAdapter("Select" + selectstr + "" + "From WebCstomer_Info Where" + "" + sel + "" + " = Like %sc%", conn)
这里面的sql语句有什么问题 sc是已赋值的字符串
NoReady 2003-10-25
  • 打赏
  • 举报
回复
也有可能是你的sql语句有问题
NoReady 2003-10-25
  • 打赏
  • 举报
回复
你用单步调试看:运行到哪句错了?这种情况一般是连接或dataadapter的问题,你那个 conn已经连接好了吗?
xmjcwo 2003-10-25
  • 打赏
  • 举报
回复
reseponse是什么
xmjcwo 2003-10-25
  • 打赏
  • 举报
回复
conn 没有问题是一个sqlconnection 测试没有问题,可以连接,这是什么异常?
mainone 2003-10-25
  • 打赏
  • 举报
回复
你的CONN有没有问题!??你是否能连上数据库
orcale 2003-10-25
  • 打赏
  • 举报
回复
Try
Dim ds As DataSet
Dim Da As SqlDataAdapter
Dim Dt As DataTable
Dim str As String '查询条件字符串
Dim selectstr As String '选择输出项字符串
。。。。。。。。。。。。。
。。。。。。。。。。。。。
Da = New SqlDataAdapter("Select Selectstr WebCstomer_Info Where sel= Like % sc% ", conn)
ds = New DataSet()
Da.Fill(ds, "WebCstomer_Info")
DataGrid1.DataSource = ds.Tables(0).DefaultView
DataGrid1.Refresh()
DataGrid1.CurrentRowIndex = 0
Catch e as SqlException
reseponse.write e.message
End Try
看看
如果是system.data.dll有問題,你到別的機器上copy一個到你的系統目錄下.版本要相同

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧