dbTalk Databases Forums  

Script error

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Script error in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Philippe
 
Posts: n/a

Default Script error - 07-05-2006 , 10:10 AM






Hi,

I want to retrieve some data with the activeX script task, but I always get
an error when I want to retrieve a field from the recordset and point it to
a local variable.
--------------------
dim countr
dim Budget

set mySourceConn = CreateObject("ADODB.Connection")
set mySourceRecordset = CreateObject("ADODB.Recordset")
mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=(local); Initial
Catalog=SSRS_Data;user id = 'user';password='pasw'"

mySQLCmdText = "SELECT Waarde as Aantal FROM [KPI-variabelen] WHERE
code='{2A1B3444-2073-47BD-B1EE-BCC4A3F1FAFE}'"

mySourceRecordset.Open mySQLCmdText, mySourceConn, 1
set Budget=mySourceRecordset.Fields("Aantal").value
----------------
The error is on the last line: Object expected,
mySourceRecordset.Fields("...").value

The recordset should contain a number (eg: 139000).

What is wrong with this ?

Thanks


Reply With Quote
  #2  
Old   
Davide Rossetti
 
Posts: n/a

Default Re: Script error - 07-05-2006 , 10:30 AM






Hello Philippe,

Quote:
Hi,

I want to retrieve some data with the activeX script task, but I
always get
an error when I want to retrieve a field from the recordset and point
it to
a local variable.
--------------------
dim countr
dim Budget
set mySourceConn = CreateObject("ADODB.Connection")
set mySourceRecordset = CreateObject("ADODB.Recordset")
mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=(local); Initial
Catalog=SSRS_Data;user id = 'user';password='pasw'"
mySQLCmdText = "SELECT Waarde as Aantal FROM [KPI-variabelen] WHERE
code='{2A1B3444-2073-47BD-B1EE-BCC4A3F1FAFE}'"

mySourceRecordset.Open mySQLCmdText, mySourceConn, 1
set Budget=mySourceRecordset.Fields("Aantal").value
----------------
The error is on the last line: Object expected,
mySourceRecordset.Fields("...").value
The recordset should contain a number (eg: 139000).

What is wrong with this ?

Thanks

in last line do not use 'set' statement. Why are you using an Activex script
in DTS to retrieve a record ? would not be better a SQL Task?
Bye




Reply With Quote
  #3  
Old   
Philippe
 
Posts: n/a

Default Re: Script error - 07-05-2006 , 10:54 AM



Hi,

Thanks, I'm uwsing the active X task because I want to do this:
- retrieve a value out of a database
- retrieve another value out of another database
- use these 2 in a calculation
- write the result to a record in a table

Can I accomplish this in another way?

Thanks

"Davide Rossetti" wrote:

Quote:
Hello Philippe,

Hi,

I want to retrieve some data with the activeX script task, but I
always get
an error when I want to retrieve a field from the recordset and point
it to
a local variable.
--------------------
dim countr
dim Budget
set mySourceConn = CreateObject("ADODB.Connection")
set mySourceRecordset = CreateObject("ADODB.Recordset")
mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=(local); Initial
Catalog=SSRS_Data;user id = 'user';password='pasw'"
mySQLCmdText = "SELECT Waarde as Aantal FROM [KPI-variabelen] WHERE
code='{2A1B3444-2073-47BD-B1EE-BCC4A3F1FAFE}'"

mySourceRecordset.Open mySQLCmdText, mySourceConn, 1
set Budget=mySourceRecordset.Fields("Aantal").value
----------------
The error is on the last line: Object expected,
mySourceRecordset.Fields("...").value
The recordset should contain a number (eg: 139000).

What is wrong with this ?

Thanks


in last line do not use 'set' statement. Why are you using an Activex script
in DTS to retrieve a record ? would not be better a SQL Task?
Bye




Reply With Quote
  #4  
Old   
Davide Rossetti
 
Posts: n/a

Default Re: Script error - 07-05-2006 , 11:15 AM



Hello Philippe,

Quote:
Hi,

Thanks, I'm uwsing the active X task because I want to do this:
- retrieve a value out of a database
- retrieve another value out of another database
- use these 2 in a calculation
- write the result to a record in a table
Can I accomplish this in another way?

Thanks

"Davide Rossetti" wrote:

Hello Philippe,

Hi,

I want to retrieve some data with the activeX script task, but I
always get
an error when I want to retrieve a field from the recordset and
point
it to
a local variable.
--------------------
dim countr
dim Budget
set mySourceConn = CreateObject("ADODB.Connection")
set mySourceRecordset = CreateObject("ADODB.Recordset")
mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=(local);
Initial
Catalog=SSRS_Data;user id = 'user';password='pasw'"
mySQLCmdText = "SELECT Waarde as Aantal FROM [KPI-variabelen] WHERE
code='{2A1B3444-2073-47BD-B1EE-BCC4A3F1FAFE}'"
mySourceRecordset.Open mySQLCmdText, mySourceConn, 1
set Budget=mySourceRecordset.Fields("Aantal").value
----------------
The error is on the last line: Object expected,
mySourceRecordset.Fields("...").value
The recordset should contain a number (eg: 139000).
What is wrong with this ?

Thanks

in last line do not use 'set' statement. Why are you using an
Activex script in DTS to retrieve a record ? would not be better a
SQL Task? Bye

You could use two different connection, two SQL Task to retrieve the two
values assigning the result of each query to a different Global Variable,
do the calculation involving the two Global vars using an ActiveX script
and assigning the result to a third Global var and,finally, use a third SQL
task to wirite your record passing the third Global var as parmeter for the
Insert (or Update) statement.
Is it good?
Bye





Reply With Quote
  #5  
Old   
Philippe
 
Posts: n/a

Default Re: Script error - 07-05-2006 , 11:29 AM



I can do that indeed; thanks :-)

"Davide Rossetti" wrote:

Quote:
Hello Philippe,

Hi,

Thanks, I'm uwsing the active X task because I want to do this:
- retrieve a value out of a database
- retrieve another value out of another database
- use these 2 in a calculation
- write the result to a record in a table
Can I accomplish this in another way?

Thanks

"Davide Rossetti" wrote:

Hello Philippe,

Hi,

I want to retrieve some data with the activeX script task, but I
always get
an error when I want to retrieve a field from the recordset and
point
it to
a local variable.
--------------------
dim countr
dim Budget
set mySourceConn = CreateObject("ADODB.Connection")
set mySourceRecordset = CreateObject("ADODB.Recordset")
mySourceConn.Open = "Provider=SQLOLEDB.1;Data Source=(local);
Initial
Catalog=SSRS_Data;user id = 'user';password='pasw'"
mySQLCmdText = "SELECT Waarde as Aantal FROM [KPI-variabelen] WHERE
code='{2A1B3444-2073-47BD-B1EE-BCC4A3F1FAFE}'"
mySourceRecordset.Open mySQLCmdText, mySourceConn, 1
set Budget=mySourceRecordset.Fields("Aantal").value
----------------
The error is on the last line: Object expected,
mySourceRecordset.Fields("...").value
The recordset should contain a number (eg: 139000).
What is wrong with this ?

Thanks

in last line do not use 'set' statement. Why are you using an
Activex script in DTS to retrieve a record ? would not be better a
SQL Task? Bye


You could use two different connection, two SQL Task to retrieve the two
values assigning the result of each query to a different Global Variable,
do the calculation involving the two Global vars using an ActiveX script
and assigning the result to a third Global var and,finally, use a third SQL
task to wirite your record passing the third Global var as parmeter for the
Insert (or Update) statement.
Is it good?
Bye





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.