数据库中我就插入了一条数据,都是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读不到数据、、
我百度好久、就是不知道要怎么弄、、、在线坐等、、、

解决方案 »

  1.   


    --你手动插入的吧,插入后commit下,然后程序中才读得到select * from student where num='11'
    --这句拿到数据库中执行看有没有结果
      

  2.   

    commit之后就好使了、、
    在数据库中执行一直都有结果的、、
    谢谢啦~
    这个要怎么给分啊、、偶不会诶、、
      

  3.   

    我还有一个问题、如果我是要插入数据、那么我是要用OracleDataAdapter吗?
    这个要怎么写啊?
      

  4.   

    要知道原因才好,简单帮你分析下,有问题再问吧你在sqlplus中操作,等于你打开了一个会话,假设会话1,你在此会话中所作的操作如果不commit,则其他会话是看不到的你在程序中调用其实就是另开了一个会话,假设会话2,因此你在会话1中如果未commit的操作,在会话2中看不到的,所以你在会话1中commit后,程序中就可看到了
      

  5.   


    '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
    '对于非数值型的,不可省的,不然会有错
    假如你愿意,有问题可直接留言给我,不一定需发帖,一般都会回的