Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue related to DB connectivity..
#1
Not Solved
Hi,
Plz find below the code for DB connectivity and help me to resolve the issue...

-----------------------------
'-----------------------* Function to get Price by Mfg part no. *----------------------
Code:
Function Connect_to_db(Byval mfgprt)

Dim cnn,rss
Set cnn = CreateObject("ADODB.Connection")
Set rss = CreateObject("ADODB.recordset")
cnn.ConnectionString = "DSN=QTPDSN;Description=desc;UID=;PWD=;APP=QuickTest Professional;WSID=;DATABASE=;"

cnn.open
rss = cnn.Execute("select  UnitPrice  from dbo.ProductProfilePrices ppp inner join priceprofiles pp on ppp.priceprofileID = pp.priceprofileID and isdefaultprofile = 1 inner join products p on ppp.productID = p.productID where MfPartNumber ='" + mfgprt + "'")
Connect_to_db=rss(0)
End Function
'--------------------------* End Function*--------------------------------------------------------------------------

'------------*GET VALUE OF MFG PART# FROM G.SHEET & SET PRICE OUTPUT VALUE in G.SHEET*-------------
Code:
row_cnt=datatable.getrowcount
for i=1 to row_cnt                                 ' For each row , do following
datatable.getsheet(i)                              ' Read Sheet 1 i.e. Global sheet
a=datatable.value("mfg",1)      'Put value of               MfgPart column from global sheet  to variable 'a'

b=Connect_to_db(a)
msgbox(b)
' Pass value of 'a' i.e. Mfgpart to function 'Connect_to_db' and put the value returned by function (i.e. Price) in variable 'b'
-----------------------------

Now what i want to do is that,while reading value from datasheet or saving value to datasheet i want to use local sheet not the global sheet...So what will be the syntax for that..


a=datatable.value("mfg",1)
what will be teh change in this syntax.
mfg col is in the local datasheet..i have 2-3 local datasheet with diff names.....



Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  QTP system related issue Bharathi Kanagarajan 1 2,105 09-12-2015, 11:28 PM
Last Post: ADITI1992
  Issue related to dropdown selection(Please help urgent) excellentpawan123 2 4,311 05-31-2014, 12:00 PM
Last Post: excellentpawan123
  Help needed on understanding the Properties and Methods related to a ActiveX control. DhivaM 2 3,987 05-21-2012, 07:48 PM
Last Post: DhivaM
  Word Related Automation nitin537 0 2,306 12-03-2011, 01:18 AM
Last Post: nitin537
  QTP AOM related Question - need solution prodipto_dutta 6 9,506 05-04-2011, 05:31 PM
Last Post: prodipto_dutta

Forum Jump:


Users browsing this thread: 2 Guest(s)