Database connection. - sudhirzpatil - 02-10-2009
Hi Friends,
I am trying to connect to a Database and importing Database Data to runtime databale.
But i am getting following error
The test run cannot continue due to a syntax error.
Expected 'Loop'
Line (28): "".
My script is as below
Code: dim con,rs
set con=createobject("adodb.connection")
set rs=createobject("adodb.recordset")
con.open"provider=sqloledb.1;server=xyz;uid=sa;pwd=sa@123;database=First"
rs.open"select * from employee",con
do while not rs.eof
datatable.getsheet(1).addparameter"Eid",""
datatable.getsheet(1).addparameter"EName",""
datatable.getsheet(1).addparameter"Salary",""
datatable.getsheet(1).addparameter"DID",""
row=1
do while not rs.EOF
databale.setcurrentrow(row)
datatable.value(1,1)=rs.fields("Eid")
datatable.value(2,1)=rs.fields("EName")
datatable.value(3,1)=rs.fields("Salary")
datatable.value(1,1)=rs.fields("DID")
row=row+1
rs.movenext
Loop
can any one point the issue.
Thnks in advance
RE: Database connection. - tarunlalwani - 02-10-2009
Code: [b]do while not rs.eof[/b]
datatable.getsheet(1).addparameter"Eid",""
datatable.getsheet(1).addparameter"EName",""
datatable.getsheet(1).addparameter"Salary",""
datatable.getsheet(1).addparameter"DID",""
row=1
[b]do while not rs.EOF[/b]
You are starting 2 loops but ending only one
RE: Database connection. - sudhirzpatil - 02-10-2009
Ohhh Yes yes....
and it runs...
thnks
RE: Database connection. - badri167 - 02-10-2009
Code: Set dtNewSheet=DataTable.AddSheet( "mysheet" )
set stNewCol1=dtNewSheet.addparameter("col1","" )
set stNewCol2=dtNewSheet.addparameter("col2","" )
set stNewCol3=dtNewSheet.addparameter("col3","" )
set conn5=Createobject( "ADODB.Connection")
Srvname5="Driver= {Microsoft ODBC forOracle}:Server= DBserver, UID=Sa,Password= sa"
conn5.open "provider=sqloledb.1;server=xyz;uid=sa;pwd=sa@123;database=First"
Set Rec5 = CreateObject("ADODB.Recordset")
SQL5="select * from employee "
Set Rec5 = conn5.execute( SQL5)
j=1
While not rec5.eof
unit=Rec5.fields("route_seq")
=Rec5.fields("id")
procesc=Rec5.fields("process")
stNewCol1.valuebyrow (j)=majprod
stNewCol2.valuebyrow (j)=orderid
stNewCol3.valuebyrow (j)=header
j=j+1
Rec5.movenext
Wend
|