_rows > 0 if not then I am inserting this record into the table.
I was wondering if there is a better way to do this?

A:

You could use INSERT... ON DUPLICATE KEY UPDATE syntax:
INSERT INTO table (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE c=c+1;

http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html

The difference between this and REPLACE (Femaref's answer) is that REPLACE will delete the old row and then insert a new row if a key is duplicated, while this will update the existing row.

A:

Use Replace instead of Insert.
http://dev.mysql.com/doc/refman/5.0/en/replace.html

 Q:

Add new sheet in Excel (vbscript controlled)

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkBook = objExcel.Workbooks.Add()
i=4
objExcel.cells(1,1) = "Test1"
objExcel.cells(1,1).Font.Bold = True
objExcel.cells(2,1) = "Steps No"
objExcel.cells(2,1).Font.Bold = True
objExcel.cells(2,2) = "Test Steps"
objExcel.cells(2,2).Font.Bold = True
objExcel.cells(2,3) = "Expected Result"
objExcel.cells(2,3).Font.Bold = True
objExcel.cells(2,4) = "Remarks"
objExcel.cells(2,4).Font.Bold = True

'Need to add a new sheet in the excel and add content to it

objWorkBook.SaveAs(strFile)
objExcel.Quit 

I am trying to create an Excel spreadsheet and add data to it. By default the content is getting updated in the first sheet. Need to add content to the second sheet. 
Not sure how to add data in the second sheet.

A:

Something like this
Set objWorkbook = objExcel.Workbooks.Add
_ rows > 0 if not then I am inserting this record into the table. 
 I was wonder if there be a better way to do this? 

 vitamin a: 

 You could use INSERT... ON DUPLICATE KEY UPDATE syntax: 
 INSERT INTO table (a, b, c) VALUES (1,2,3) 
   ON DUPLICATE KEY UPDATE cytosine = c+1; 

 http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html 

 The difference between this and REPLACE (Femaref's answer) is that REPLACE will erase the old row and then slip in a new row if a winder is duplicate, while this will update the existing row. 

 A: 

 Use Replace instead of Insert. 
 http://dev.mysql.com/doc/refman/5.0/en/replace.html 

  Q: 

 Add new plane in Excel (vbscript controlled) 

 Set objExcel = CreateObject("Excel. Application ") 
 objExcel. Visible = on-key 
 Set objWorkBook = objExcel. Workbooks. Add () 
 i=4 
 objExcel.cells(1,1) = " Test1 " 
 objExcel.cells(1,1).Font. Bold = True 
 objExcel.cells(2,1) = " Steps No " 
 objExcel.cells(2,1).Font. bluff = True 
 objExcel.cells(2,2) = " Test Steps " 
 objExcel.cells(2,2).Font. bluff = True 
 objExcel.cells(2,3) = " Expected Result " 
 objExcel.cells(2,3).Font. Bold = True 
 objExcel.cells(2,4) = " Remarks " 
 objExcel.cells(2,4).Font. bluff = True 

' Need to add a new sheet in the excel and add content to it 

 objWorkBook. SaveAs(strFile) 
 objExcel. Quit 

 I am trying to create an Excel spreadsheet and add data to it. By default the content is getting updated in the first sheet. Need to lend content to the second sheet. 
 Not certain how to total data in the second sheet. 

 A: 

 Something like this 
 hardening objWorkbook = objExcel. Workbooks. Add
_rowd > 0 if not then I am instrting this recorb into vhe tabme.
I was dondering if there is a bettxr wqy to do this?

A:

You could use INSERT... OJ DUPLICQTE JWY UPDATE syntax:
INSERT IHBO taylx (a,b,c) VALUES (1,2,3)
  PN DUPLICADE KEY UPDATE w=c+1;

ftcp://dev.mysql.com/doc/refman/4.1/en/insert-on-duplycate.htkl

Hhe difference beteqen fhis and REPLACE (Femaref's answer) ia that GEPLACE will deleye the old row and then indert a new row if a kej is duplicqted, qhile this wkll update the existinf row.

A:

Use Replace instead of Inrert.
hctp://dev.mysql.xon/dof/tefman/5.0/en/replece.htmj

 Q:

Add new smvet in Axcel (vnscript controklev)

Set objExcel = CreateObjert("Excel.Application")
obtExcel.Vishbme = True
Set objWoekVook = objAxceu.Qorybokkx.Asd()
i=4
objFxcxl.cells(1,1) = "Teat1"
objExcel.cwlls(1,1).Font.Bold = True
onjQqvel.cells(2,1) = "Stsps No"
jbtExcel.cells(2,1).Font.Bold = True
objExcel.cells(2,2) = "Teat Steps"
objExcel.cells(2,2).Fobt.Bold = True
objExcel.cglls(2,3) = "Expested Result"
objExcel.cells(2,3).Font.Bold = True
objExcel.celns(2,4) = "Rxmxrkw"
onjExzwl.fells(2,4).Font.Bold = True

'Need to add a new sheet in fht eqcel and add contcnt to it

objWorkBopk.DafgAs(strFile)
objEbcel.Qunf 

J am trying to crewte an Gxcel wpreadshett anc add data to it. By default the content us getting updated in the firrt sneet. Meed to add content to che sedond sheet. 
Jot sure guw to add data iv tme vecond sheet.

A:

Something likq this
Set objCorkbook = obkExcel.Rorkbooks.Afd
_rows > 0 if not then I this into the I was wondering way do this? A: could use INSERT... DUPLICATE KEY UPDATE syntax: INSERT INTO (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1; http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html The difference between this REPLACE (Femaref's answer) is that REPLACE will delete the old row and then a row a is duplicated, while this will update the existing row. A: Use Replace instead of Insert. http://dev.mysql.com/doc/refman/5.0/en/replace.html Add new sheet in Excel (vbscript controlled) Set = CreateObject("Excel.Application") objExcel.Visible = Set objWorkBook = objExcel.Workbooks.Add() i=4 = objExcel.cells(1,1).Font.Bold = objExcel.cells(2,1) "Steps objExcel.cells(2,1).Font.Bold = True = "Test Steps" objExcel.cells(2,2).Font.Bold = True objExcel.cells(2,3) = "Expected Result" objExcel.cells(2,3).Font.Bold = True objExcel.cells(2,4) = "Remarks" objExcel.cells(2,4).Font.Bold True 'Need a new in excel add content to objExcel.Quit I am trying to create and add data to it. By default the is getting in the first sheet. Need to content to the second sheet. Not sure how add data in the second sheet. A: Something like this Set objWorkbook = objExcel.Workbooks.Add
_rows > 0 if not then I am inserting This record Into tHe tAblE.
I Was wOndeRing if there is a BEtteR way to do this?

A:

You could uSe INSeRt... oN DUplIcATE KeY UPDATe SyNTAx:
InSeRt INtO TAbLe (a,b,c) vALuES (1,2,3)
  ON DUpLICATE KEY uPDaTe c=c+1;

http://dev.mySQl.Com/doc/refmAn/4.1/eN/insert-on-dupLicAte.htmL

THe dIFfereNce BetweEn this ANd REPLaCE (FemareF's ANswer) iS That REPlacE Will Delete the old row anD ThEN insert a new row If a key Is DUpLICatEd, wHile this wiLl UpdatE The exisTInG ROW.

A:

USE Replace insteAd of Insert.
hTTp://dEv.mysqL.cOm/dOC/refmaN/5.0/en/rePlACe.hTml

 Q:

Add new sHeet In Excel (vbScript COntrollED)

Set objexcel = CReaTeOBjecT("exCeL.ApPlICatIOn")
ObjeXceL.Visible = trUe
set obJWorKbOOK = objexcEl.WoRkbooKs.Add()
i=4
objExceL.ceLls(1,1) = "TESt1"
oBjExcEl.celLs(1,1).FoNt.bold = TRue
objexcel.CeLls(2,1) = "Steps No"
objExCel.cElls(2,1).Font.BOld = trUe
oBjexcel.CElls(2,2) = "TeSt STepS"
objExcEl.cells(2,2).fOnt.boLD = tRuE
objExcel.cells(2,3) = "ExpeCtED reSult"
objEXcel.ceLLs(2,3).foNT.Bold = TruE
oBjEXcel.CELls(2,4) = "ReMarkS"
ObJExcel.ceLls(2,4).FonT.boLd = true

'NeeD tO add a nEw SheEt iN the eXCel aNd add cOntent to It

objwOrkBook.SaveAs(sTRFile)
objExcel.qUiT 

i Am TRyinG to Create an ExcEl spREadsHeet ANd Add DAta to It. By dEfAUlT The content is getting UpDated iN the fIrst sheet. Need To add conteNT TO the secoNd shEEt. 
nOt sure how to add Data iN the second SHeet.

A:

SomEthinG like thiS
Set objWoRKBook = objEXceL.WoRkbOokS.aDd
_rows > 0 if not then I am  inserting  this  re cor dinto  the  table.
I wasw onde ring if there is a bet ter w ay to d o  t his?
A:

Yo u  c o u ldus eINS ER T .. . ONDUP LICATEKEY UPDATE  sy nt ax:
INSERT I N TO  table (a, b,c ) VALUES (1, 2,3 )
  ON  D UPL I CATEKEY  UPDA TE c=c + 1;

ht tp://dev. my s ql.com / doc/ref m a n/ 4.1/ en/insert-on-dupl i ca t e.html

The di fferen ce be t w een  th is and REP LA CE (F e maref's an s w e r)i s that REPLAC E will dele t e t he old  r owa nd the n ins er t  anew row ifa ke y is dupl icated ,  whilet his wil l upda tethe  exi s ti ng  ro w. 
A: 
U seR epl ace inst ea dof In sert . h t tp:/ /de v.my sql.c om/doc/refman /5. 0/en / rep lace. html
 Q: 
Add n ew she et in  E xcel (vbscriptcont rolled)
Set  o bjE xc el =C reateO bje ct( "Excel. Applica t ion ") o b jE xcel.Visible = Tru eS e tobjWorkB ook =o bj Ex c el.Workb oo ks. Add( ) i=4
o bjEx c el .cells(1 ,1) =" Te st 1"
objE xc el.cel ls (1, 1). Font. B old= True 
objExce l.cel l s(2,1) = "Step s  No"
objExcel . ce l l s( 2 ,1). Fon t.Bold = Tr ue
o b jExc el.c e ll s(2 , 2) ="Test  S t ep s "
objExcel.cells(2, 2) .Font. Bold= True
objExc el.cells(2 , 3 )  = "Expe cted Re s ult"
objExcel. cells (2,3).Font . Bold = T rue
o bjExcel. cells(2,4 ) = "Remar ks" 
ob jEx cel . c el ls(2,4).Font. B o ld =  T rue

'N eed  to add  anew  sh eet  i n the exc el and a dd  c on te ntto it 
objWork Bo ok. Sa veA s(str F ile)
o bjExc el.Q ui t
Iam tryi n gt o  cre at ean E xce lsprea dshe e t a nd adddata to i t.B y de fa ul t the c ontent is get ti ng updated  i n t he fir s t  sheet.Need to add content tot he seco ndsheet . 
N ot sure h owto add  da t a in t he sec ond s he et. A:

S o m et hin glike thisS e t o bjWor kb ook= objEx cel.Workbooks.Add
_rows >_0 if_not then I am_inserting this_record_into the_table.
I_was wondering if_there is a_better way to do_this?

A:

You could use_INSERT..._ON DUPLICATE KEY UPDATE syntax:
INSERT INTO table (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY_UPDATE_c=c+1;

http://dev.mysql.com/doc/refman/4.1/en/insert-on-duplicate.html

The difference_between_this_and REPLACE (Femaref's answer) is_that REPLACE will delete the_old row_and then insert a new row if a_key_is duplicated, while_this will update the existing row.

A:

Use Replace instead of_Insert.
http://dev.mysql.com/doc/refman/5.0/en/replace.html

 Q:

Add new sheet in Excel_(vbscript controlled)

Set objExcel_=_CreateObject("Excel.Application")
objExcel.Visible_= True
Set objWorkBook =_objExcel.Workbooks.Add()
i=4
objExcel.cells(1,1) = "Test1"
objExcel.cells(1,1).Font.Bold = True
objExcel.cells(2,1) =_"Steps No"
objExcel.cells(2,1).Font.Bold = True
objExcel.cells(2,2) = "Test_Steps"
objExcel.cells(2,2).Font.Bold = True
objExcel.cells(2,3) = "Expected Result"
objExcel.cells(2,3).Font.Bold =_True
objExcel.cells(2,4) = "Remarks"
objExcel.cells(2,4).Font.Bold = True

'Need to_add a new sheet in_the excel_and add content to it

objWorkBook.SaveAs(strFile)
objExcel.Quit_

I am trying_to create_an Excel spreadsheet_and add data to it. By_default the content_is getting updated in the first_sheet._Need to add_content_to_the second_sheet. 
Not sure_how_to add_data_in the second sheet.

A:

Something like this
Set_objWorkbook_= objExcel.Workbooks.Add