回 帖 发 新 帖 刷新版面

主题:有点问题,哪位大虾帮忙给改改啊

这段代码有点问题,我想要把表中的数据修改成我用select 语句检索出来的数据,可是他把所有记录都给更新成取到的最后一条 数据 拉  ,迷糊阿!!!
Dim commm As OracleClient.OracleCommand
        Dim commm1 As OracleClient.OracleCommand
        Dim datareader As System.Data.IDataReader
        commm = OracleConnection1.CreateCommand()
        commm.CommandText = "SELECT SP_NAME,SP_COLOR,SP_NUM,SP_SIZE,SP_CUP FROM Z_T_COMMODITY WHERE LX1='" + TextBox1.Text + "' AND LX2='" + TextBox3.Text + "' AND LX3='" + TextBox2.Text + "' "
        OracleConnection1.Open()
        datareader = commm.ExecuteReader()
        Do While datareader.Read
         commm.CommandText = "UPDATE Z_TP SET SP_NAME='" & datareader(0) & "',SP_COLOR='" & datareader(1) & "',SP_NUM='" & datareader(2) & "'"
            commm.CommandType = CommandType.Text
            commm.ExecuteNonQuery()
        Loop
        OracleConnection1.Close()
        OracleDataAdapter1.Fill(DataSet11.Z_TP)
[em78][em78][em78][em78][em78][em78][em78][em78][color=00FF00]有点问题,哪位大虾帮忙给改改啊[/color]

回复列表 (共1个回复)

沙发

你试试看这样的行不行,呵呵,我也才学了半个月[em8]

commm.CommandText &= "UPDATE Z_TP SET SP_NAME='" & datareader(0) & "',SP_COLOR='" & datareader(1) & "',SP_NUM='" & datareader(2) & "'"

我来回复

您尚未登录,请登录后再回复。点此登录或注册