新手求助求助、坐等、、

bengyou 2012-08-15 02:55:01
数据库中我就插入了一条数据,都是11的、、
-----------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSql As String
strSql = "select * from student where num='11'" ' & TextBox1.Text
Dim sqlconnStr As String
sqlconnStr = "Data Source=***;user=system;password=***"
Try

Dim SqlConn = New System.Data.OracleClient.OracleConnection(sqlconnStr)
MsgBox("start")
SqlConn.open()
Dim sqlcmd As System.Data.OracleClient.OracleCommand = New System.Data.OracleClient.OracleCommand(strSql, SqlConn)
Dim dr As System.Data.OracleClient.OracleDataReader
dr = sqlcmd.ExecuteReader()
MsgBox("11")
If dr.Read() Then
MsgBox("ok")
Else
MsgBox(dr.Read())
MsgBox("error11")
End If
SqlConn.close()
Catch
MsgBox("error")
End Try

End Sub
-------------------------
dr读不到数据、、
我百度好久、就是不知道要怎么弄、、、在线坐等、、、
...全文
88 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
bengyou 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 的回复:]
VB.NET code


'strSql = "select * from student where num='11'" ' & TextBox1.Text
'对于数值型的,你可以省去查询条件两边的'',即可写成你后面传参的那种
strSql = "select * from student where num=11" ' & TextBox1.Text
'或
s……
[/Quote]
那以后就麻烦你拉~我有好多问题的、、
人生无悔 2012-08-15
  • 打赏
  • 举报
回复

'strSql = "select * from student where num='11'" ' & TextBox1.Text
'对于数值型的,你可以省去查询条件两边的'',即可写成你后面传参的那种
strSql = "select * from student where num=11" ' & TextBox1.Text
'或
strSql = "select * from student where num=11" & TextBox1.Text
'对于非数值型的,不可省的,不然会有错


假如你愿意,有问题可直接留言给我,不一定需发帖,一般都会回的
bengyou 2012-08-15
  • 打赏
  • 举报
回复
明白了~谢谢大哥~
bengyou 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
点结贴,然后把分给我,谢谢。
[/Quote]
乃又木有帮偶解决问题、、、偶干嘛要把分给你、、
人生无悔 2012-08-15
  • 打赏
  • 举报
回复
要知道原因才好,简单帮你分析下,有问题再问吧

你在sqlplus中操作,等于你打开了一个会话,假设会话1,你在此会话中所作的操作如果不commit,则其他会话是看不到的

你在程序中调用其实就是另开了一个会话,假设会话2,因此你在会话1中如果未commit的操作,在会话2中看不到的,所以你在会话1中commit后,程序中就可看到了
ORAClE SE 2012-08-15
  • 打赏
  • 举报
回复
点结贴,然后把分给我,谢谢。
bengyou 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
以后会了再结吧,问题解决了就好,用的时间久了就会了,呵呵
[/Quote]
我还有一个问题、如果我是要插入数据、那么我是要用OracleDataAdapter吗?
这个要怎么写啊?
人生无悔 2012-08-15
  • 打赏
  • 举报
回复
以后会了再结吧,问题解决了就好,用的时间久了就会了,呵呵
bengyou 2012-08-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
SQL code


--你手动插入的吧,插入后commit下,然后程序中才读得到

select * from student where num='11'
--这句拿到数据库中执行看有没有结果
[/Quote]
commit之后就好使了、、
在数据库中执行一直都有结果的、、
谢谢啦~
这个要怎么给分啊、、偶不会诶、、
bengyou 2012-08-15
  • 打赏
  • 举报
回复
貌似好了诶、、谢谢大哥~不过这个怎么给分啊、、偶不会诶、、
bengyou 2012-08-15
  • 打赏
  • 举报
回复
貌似好了诶、、谢谢大哥~不过这个怎么给分啊、、偶不会诶、、
人生无悔 2012-08-15
  • 打赏
  • 举报
回复

--你手动插入的吧,插入后commit下,然后程序中才读得到

select * from student where num='11'
--这句拿到数据库中执行看有没有结果
bengyou 2012-08-15
  • 打赏
  • 举报
回复
木有人么、木有人么、、快来人帮帮偶吧、、偶要纠结死了、、

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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