commandtext属性尚未初始化为vb.net

时间:2014-10-02 06:20:19

标签: vb.net oracle

我是vb.net的新手并尝试执行其工作正常的代码但是当我通过仅运行exe文件在网络中的另一台服务器中安排代码时,我收到的错误为:

  

“commandtext属性尚未初始化”

Sub send_SMS()
    Console.WriteLine("Begining of the send_SMS() ")
    Dim dt As New DataTable
    Dim st1, sql As String
    Dim fetcheduser, fetchedpno As String
    Dim J As Integer
    J = Now.Hour
    Console.WriteLine("J Now.Hour =: " + J.ToString)
    'A shift
    If J >= 14 And J < 22 Then
        sql = " SELECT * FROM YKPI_VALUE "
        sql = sql & " WHERE KPV_USER_ID='QEXP' "
        sql = sql & " AND KPV_TYP_ID='A'  "
        sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE,'YYYYMMDD') "
        Console.WriteLine("J = 14 ")
        st.Text = "A"
    End If

    'B Shift
    If J >= 22 And J < 6 Then
        sql = " SELECT * FROM YKPI_VALUE "
        sql = sql & " WHERE KPV_USER_ID='QEXP' "
        sql = sql & " AND KPV_TYP_ID='B'  "
        sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE,'YYYYMMDD') "
        Console.WriteLine("J = 22 ")
        st.Text = "B"
    End If

    'C Shift
    If J >= 6 And J < 14 Then
        sql = " SELECT * FROM YKPI_VALUE "
        sql = sql & " WHERE KPV_USER_ID='QEXP' "
        sql = sql & " AND KPV_TYP_ID='C'  "
        sql = sql & " AND KPV_FROM_DATE=TO_CHAR(SYSDATE-1,'YYYYMMDD') "
        Console.WriteLine("J = 6 ")
        st.Text = "C"
        DAT = DAT.AddDays(-1)

    End If


    Dim DA As New OracleDataAdapter(sql, oraconn)
    DA.Fill(dt)



    Console.WriteLine("Before dt.Rows count ")
    Dim MaxRows, MaxColums, inc As Integer
    MaxRows = dt.Rows.Count
    MaxColums = dt.Columns.Count
    Dim multiarray(,) As String = New String(MaxRows, MaxColums) {}
    Console.WriteLine("Value of MaxRows = " + MaxRows.ToString)
    Console.WriteLine("Value of MaxColums = " + MaxColums.ToString)
    If (inc <> MaxRows) Then
        'inc = inc + 1
        Console.WriteLine("Inside dt.Rows and Before for loop ")


        For inc = 0 To MaxRows - 1

            'For col = 0 To MaxColums
            dt.Rows(inc).Item(10) = dt.Rows(inc).Item(10).ToString.Replace("Q", "")
            multiarray(inc, 1) = dt.Rows(inc).Item(2).ToString()
            multiarray(inc, 2) = dt.Rows(inc).Item(4).ToString()
            multiarray(inc, 3) = dt.Rows(inc).Item(10).ToString()
        Next

    End If

    Dim queryusr As String
    queryusr = ""
    Dim sql_CMD_TD As New OracleCommand(sql, oraconn)
    If Not oraconn.State = ConnectionState.Open Then
        oraconn.Open()
    End If
    Dim doNotSendSMS = False
    Dim sqldr As OracleDataReader = sql_CMD_TD.ExecuteReader()

    If sqldr.HasRows Then
        oraconn.Close()

        queryusr = " SELECT TSU_USER,TSU_USERNAME FROM T_SDM_USERS "
        queryusr = queryusr & "WHERE TSU_SCREENID='QESMS'AND TSU_VALIDITY='Y' "

        dt = New DataTable
        DA = New OracleDataAdapter(queryusr, oraconn)
        DA.Fill(dt)

        If Not doNotSendSMS Then
            Dim ora_CMD_SMS As New OracleCommand(queryusr, oraconn)
            If oraconn.State = ConnectionState.Closed Then
                oraconn.Open()
            End If
            st1 = st.Text
            Dim ORA_DR As OracleDataReader = ora_CMD_SMS.ExecuteReader()

            If ORA_DR.HasRows Then
                While ORA_DR.Read()

                    fetcheduser = ORA_DR("TSU_USERNAME")
                    fetchedpno = ORA_DR("TSU_USER")
                    Console.WriteLine("Before insertIntoSMS function call ")
                    Console.WriteLine(" Value of st1 :" + st1.ToString)
                    insertIntoSMS_hbf(fetcheduser, fetchedpno, st1, multiarray, MaxRows, MaxColums)
                    Console.WriteLine("Outside of insertIntoSMS function call ")
                End While
                ORA_DR.Close()
            End If


            If oraconn.State = ConnectionState.Open Then
                oraconn.Close()
            End If

        End If
    End If
End Sub

0 个答案:

没有答案