Facebook

For any corporate training requirements Please mail To sudhakar@qtpsudhakar.com
Course Name Date Time Duration Type Location
WhatsApp to 91-8328152362 for address details of AnyTechLabs
Selenium + Appium 27th February 2019 7.00 AM IST to 8:45 AM IST 45 Days Class Room + Online AnyTechLabs
Selenium + Appium 9th March 2019 9.00 AM IST to 2.00 PM IST 5 WeekEnds Class Room + Online AnyTechLabs

A book "Cracking the QTP interview" authored by Sudhakar.Read More. Buy From FlipKart

Wednesday, June 10, 2009

How to connect to SQL without DSN?


'******************************************************
Set oCon=createobject("ADODB.connection")

oCon.open="Provider=SQLOLEDB;Data Source=computerName; Trusted_Connection=Yes;Initial Catalog=database_name;User ID=username;Password=password;"

set oData=oCon.execute("select * from table_name")

oFields=oData.fields.count

For oFld=0 to oFields-1

 fldName=oData.fields(oFld).name
   
 oval=""
   
  While not oData.eof
   oval=oval&oData(fldName)&vbnewline
   oData.movenext
  Wend
   
 msgbox oval,vbokonly,fldName
 oData.movefirst
   
Next

'******************************************************

1 comment :

  1. Awesome! Huge help. I would suggest throwing some comments in the code within the for...next loop to help those of us new to connecting to SQL in scripts. Thanks!

    ReplyDelete