我正在尝试以下代码,但出现以下错误:
ex = {"Conversion from string "INSERT INTO d009040 (LBRCODE,ENT" to type 'Double' is not valid."}。
ex = {"Conversion from string "INSERT INTO d009040 (LBRCODE,ENT" to type 'Double' is not valid."}
请帮忙。到目前为止,我可以使用更长的SQL查询。:(
Dim cmd3 As New OracleCommand cmd3.Connection = conn Dim timepara As String = Now.Hour & Now.Minute & Now.Second & Now.Millisecond cmd3.CommandText = "INSERT INTO d009040 (LBRCODE,ENTRYDATE,BATCHCD,SETNO,SCROLLNO,MAINSCROLLNO,POSTDATE,FEFFDATE,ACTIVITYTYPE,CASHFLOWTYPE,VALUEDATE,BOOKTYPE,DRCR,VCRACCTID,MAINACCTID,MAINMODTYPE,VCRMODTYPE,TRNCURCD,FCYTRNAMT,LCYCONVRATE,LCYTRNAMT,INSTRBANKCD,INSTRBRANCHCD,INSTRTYPE,INSTRNO,INSTRDATE,TOKENNO,PARTICULARS,SYSGENVCR,SHTOTFLAG,SHCLRFLAG,ACTOTFLAG,ACCLRFLAG,MAKER,MAKERDATE,MAKERTIME,CHECKER1,CHECKER2,CHECKER3,CHECKER4,CHECKERDATE,CHECKERTIME,NOAUTHPENDING,NOAUTHOVER,POSTFLAG,AUTHFLAG,FEFFFLAG,CANCELEDFLAG,POSTAUTHFEFFCNCL,UPDTCHKID,PARTCLEARAMT,POSTTIME) VALUES ('" + lbr + "','" + datepara + "','TR-MOBDS','" + k + "','" + k + "','" + k + "','" + datepara + "','" + datepara + "','CR','CR','" + datepara + "','ZZ','C','" + internalaccount + "','" + internalaccount + "','47','47','INR','" + amount + "','1','" + amount + "','0','0','99','000000000000','" + datepara + "','0','DDS CR. From Agent','1','Y','Y','Y','Y','0','" + datepara + "','" + timepara + "','0','0','0','0','" + datepara + "','" + timepara + "','0','1','P','A','F','0','0','0','0','" + timepara + "')" cmd3.CommandType = CommandType.Text cmd3.ExecuteNonQuery()
您应该真正Parameters避免使用SQL- Injection和此类错误。
Parameters
例如:
Using con = New OracleConnection(connectionString) Dim sql = "INSERT INTO d009040 (LBRCODE,ENTRYDATE,BATCHCD,SETNO,SCROLLNO,MAINSCROLLNO,POSTDATE,FEFFDATE,ACTIVITYTYPE,CASHFLOWTYPE,VALUEDATE,BOOKTYPE,DRCR,VCRACCTID,MAINACCTID,MAINMODTYPE,VCRMODTYPE,TRNCURCD,FCYTRNAMT,LCYCONVRATE,LCYTRNAMT,INSTRBANKCD,INSTRBRANCHCD,INSTRTYPE,INSTRNO,INSTRDATE,TOKENNO,PARTICULARS,SYSGENVCR,SHTOTFLAG,SHCLRFLAG,ACTOTFLAG,ACCLRFLAG,MAKER,MAKERDATE,MAKERTIME,CHECKER1,CHECKER2,CHECKER3,CHECKER4,CHECKERDATE,CHECKERTIME,NOAUTHPENDING,NOAUTHOVER,POSTFLAG,AUTHFLAG,FEFFFLAG,CANCELEDFLAG,POSTAUTHFEFFCNCL,UPDTCHKID,PARTCLEARAMT,POSTTIME) VALUES (:LBRCODE,:ENTRYDATE,:BATCHCD,:SETNO,:SCROLLNO,:MAINSCROLLNO,:POSTDATE,:FEFFDATE,:ACTIVITYTYPE,:CASHFLOWTYPE,:VALUEDATE,:BOOKTYPE,DRCR,:VCRACCTID,:MAINACCTID,:MAINMODTYPE,:VCRMODTYPE,:TRNCURCD,:FCYTRNAMT,:LCYCONVRATE,:LCYTRNAMT,:INSTRBANKCD,:INSTRBRANCHCD,:INSTRTYPE,:INSTRNO,:INSTRDATE,:TOKENNO,:PARTICULARS,:SYSGENVCR,:SHTOTFLAG,:SHCLRFLAG,:ACTOTFLAG,:ACCLRFLAG,:MAKER,:MAKERDATE,:MAKERTIME,:CHECKER1,:CHECKER2,:CHECKER3,:CHECKER4,:CHECKERDATE,:CHECKERTIME,:NOAUTHPENDING,:NOAUTHOVER,:POSTFLAG,:AUTHFLAG,:FEFFFLAG,:CANCELEDFLAG,:POSTAUTHFEFFCNCL,:UPDTCHKID,:PARTCLEARAMT,:POSTTIME)" Using cmd = New OracleCommand(sql, con) con.Open() cmd.Parameters.AddWithValue(":LBRCODE", LBRCODE) ' add the other parameters as well ... ' dim result = cmd.ExecuteNonQuery() End Using End Using
请注意,我已经很久没有使用oracle了,所以可能出了点问题,但是我还是希望您能理解。