sql server - Delete SQL rows from Excel with Time Values -
i having trouble trying work here when columns have time data types. works when use on different tables not have time data types. want able delete
sql rows in specific table script below.
sub button1_click() dim conn adodb.connection dim cmd adodb.command dim strsql string strsql = "delete dbo.timelog eventdate = ? , id = ? , deptcode = ? , opcode = ? , starttime = ? , finishtime = ? , units = ?;" set conn = new adodb.connection conn.open "provider=sqloledb;data source=blank;initial catalog=blank;user id=blank;password=blank;" 'skip header row irowno = 2 sheets("sheet1") 'loop until empty cell in firstname until .cells(irowno, 1) = "" set cmd = new adodb.command cmd.activeconnection = conn cmd.commandtype = adcmdtext cmd.commandtext = strsql cmd.parameters.append _ cmd.createparameter("peventdate", advarchar, adparaminput, 15, .cells(irowno, 1)) cmd.parameters.append _ cmd.createparameter("pid", adinteger, adparaminput, , .cells(irowno, 2)) cmd.parameters.append _ cmd.createparameter("pdeptcode", advarchar, adparaminput, 2, .cells(irowno, 3)) cmd.parameters.append _ cmd.createparameter("popcode", advarchar, adparaminput, 2, .cells(irowno, 4)) cmd.parameters.append _ cmd.createparameter("pstarttime", addbtime, adparaminput, 0, .cells(irowno, 5)) cmd.parameters.append _ cmd.createparameter("pfinishtime", addbtime, adparaminput, 0, .cells(irowno, 6)) cmd.parameters.append _ cmd.createparameter("punits", adinteger, adparaminput, , .cells(irowno, 7)) cmd.execute irowno = irowno + 1 loop msgbox "data deleted" end conn.close set conn = nothing end sub
here error code receiving.
`run-time error '-2147217900 (80040e14)': data types time , datetime incompatible in equal operator`
its got basic, not seeing it, appreciated., thanks
Comments
Post a Comment