Delete SQL rows from Excel -


i trying use excel macro delete specific rows sql table, have script insert , tweaked little no avail. can 1 out please. here im trying

sub button1_click() dim conn adodb.connection dim cmd adodb.command  dim strsql string  strsql = "delete dbo.associateinfo" & _ " (id, firstname, lastname, hiredate) " & _ " = (?,?,?,?);"  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("pid", advarchar, adparaminput, 8, .cells(irowno, 1))   cmd.parameters.append _     cmd.createparameter("pfirstname", advarchar, adparaminput, 30, .cells(irowno, 2))   cmd.parameters.append _     cmd.createparameter("plastname", advarchar, adparaminput, 30, .cells(irowno, 3))   cmd.parameters.append _     cmd.createparameter("phiredate", advarchar, adparaminput, 10, .cells(irowno, 4))    cmd.execute    irowno = irowno + 1   loop    msgbox "data exported"  end  conn.close set conn = nothing end sub 

im thinking have delete script incorrect.

here how when used insert

strsql = "insert dbo.associateinfo" & _ "(id, firstname, lastname, hiredate) " & _ "values (?,?,?,?);" 

i got it, have have strsql show correct sql query

strsql = "delete dbo.associateinfo id = ? , firstname = ? , lastname = ? , hiredate = ?;" 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -