Results 1 to 7 of 7

Thread: passing "Where" value with Prepared Statement?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    145

    passing "Where" value with Prepared Statement?

    Hi, i have this

    Code:
        Set cmdSQLPembayaran = New ADODB.Command
        With cmdSQLPembayaran
            .ActiveConnection = objConnMarketing
            .Prepared = True
            .Parameters.Append .CreateParameter("Periode", adChar, adParamInput, 6)
            .Parameters.Append .CreateParameter("Site", adChar, adParamInput, 1)
            .Parameters.Append .CreateParameter("Slip", adChar, adParamInput, 11)
            .Parameters.Append .CreateParameter("Faktur", adChar, adParamInput, 9)
            .Parameters.Append .CreateParameter("NotaBank", adChar, adParamInput, 9)
            .Parameters.Append .CreateParameter("TanggalSlip", adDate, adParamInput)
            .Parameters.Append .CreateParameter("SudahBayar", adDouble, adParamInput)
            .Parameters.Append .CreateParameter("BayarPokok", adDouble, adParamInput)
            .Parameters.Append .CreateParameter("BayarDenda", adDouble, adParamInput)
            .Parameters.Append .CreateParameter("BayarLebih", adDouble, adParamInput)
            .Parameters.Append .CreateParameter("Slip", adChar, adParamInput, 11)
        End With
    
    
    
        varStrSql = " UPDATE pembayaran SET Periode = ?, Site = ?, Slip = ?, Faktur = ?, NotaBank = ?,  " _
                    & " TanggalSlip = ?, SudahBayar = ?, BayarPokok = ?, BayarDenda = ?, BayarLebih = ? " _
                    & " WHERE Slip = ?"
        With cmdSQLPembayaran
            .CommandType = adCmdText
            .CommandText = varStrSql
        End With
        For x = 1 To (fg.Rows - 1)
                    'cmdSQLPembayaran("Periode") = TAHUN & BULAN
                    'cmdSQLPembayaran("Site") = SITE
                    'cmdSQLPembayaran("NotaBank") = Trim(RemoveChar(myCmbNotaBank.Text, "."))
                    'cmdSQLPembayaran("TanggalSlip") = mytTanggalSetor.Text
                    
                    cmdSQLPembayaran("Slip") = Trim(RemoveChar(fg.TextMatrix(x, 0), ".")) & Trim(fg.TextMatrix(x, 1))
                    cmdSQLPembayaran("Faktur") = Trim(RemoveChar(fg.TextMatrix(x, 0), "."))
                    cmdSQLPembayaran("SudahBayar") = CCur(Trim(fg.TextMatrix(x, 4)))
                    cmdSQLPembayaran("BayarPokok") = CCur(Trim(fg.TextMatrix(x, 6)))
                    cmdSQLPembayaran("BayarDenda") = CCur(Trim(fg.TextMatrix(x, 7)))
                    cmdSQLPembayaran("BayarLebih") = CCur(Trim(fg.TextMatrix(x, 8)))
                    cmdSQLPembayaran.Execute , , adCmdText + adExecuteNoRecords       'Ctatan: the last two arguments used for Execute here makes the execution of the command faster
                    Debug.Print "masuk " & Trim(RemoveChar(fg.TextMatrix(x, 0), ".")) & Trim(fg.TextMatrix(x, 1))
        Next
    I already debug "Slip" Parameter it should meet the condition. But somehow it never meet any condition that it should. What's wrong with my code above?
    Should i create new parameter object for "Slip" since it "calling" twice, once in UPDATE and once in WHERE CLAUSE?
    Should i create different parameter object (adParamOutput, adParamReturnValue, etc) for "Slip" that will use in WHERE Clause?

    Please help....
    Last edited by barianto; Apr 11th, 2007 at 10:10 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width