Showing posts with label similar. Show all posts
Showing posts with label similar. Show all posts

Monday, March 12, 2012

Help! Creating Custom Data Flow Task

I'm trying to create a custom data flow destination, and it has a custom property that needs to get value from variable(similar to the FileNameVariable property of Raw File Destination), how can I do that?

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

|||

DarrenSQLIS wrote:

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

So provide a custom IDTSCustomProperty90 in ProvideComponentProperties() and let users type in the variable name is enough(of course, I should also follow what you said)?

I wanted to make it behave the same way as the FileNameVariable property of Raw File Destination, that is: users don't type in the variable name, instead, they select from all available variable names.
|||

DarrenSQLIS wrote:

Create a propery of type string. Store the name of a variable in that property. Use the property value to locate the variable in the variables collection at run-time, lock and read the variable's value.

What are you asking? How to create a property? How to store a string in a property, the string being a variable name? How to read a string value from a property and get the matching varible and it's value at runtime?

You should also validate the value of the property during Validate of course, and check tht it is a valid variable name.

How can I get the matching variable and it's value at runtime? And generally in which method should I do that? Thanks.
|||

Here's a sample from a component I developed to raise custom events from a package's control flow; the same basic technique should work for you in data flow as well.

First, create a property that stores the variable name. This will be set by the package developer at design time.

Code Snippet

private string variableName;

///

/// This property gets or sets the name of the variable in which the

/// event text is stored.

///

[Browsable(true)]

[Category("Custom")]

[Description("Gets or sets the name of the variable in which the event text is stored.")]

public string VariableName

{

get

{

return variableName;

}

set

{

if (value.IndexOf("::") == -1)

{

variableName = "User::" + value;

}

else

{

variableName = value;

}

}

}

(The set accessor for the property is simply explicitly adding the User namespace to the specified variable name unless a namespace is already specified. I've yet to add a drop-down so the package developer can pick from a list of available variables.)

Then, you can use the component's VariableDispenser object (which is passed in a parameter to many of the methods you overload when developing your component) to lock and work with the package variable identified by the property. Here's a sample from the Validate method in my component:

Code Snippet

Variables vars = null;

DTSExecResult result;

variableDispenser.LockOneForRead(variableName, ref vars);

if (vars[variableName].DataType != TypeCode.String)

{

// The variable is accessable, but is not the correct data type

componentEvents.FireError(0, SubComponent(variableDispenser),

string.Format("Variable '{0}' is not a String variable", variableName), "", 0);

result = DTSExecResult.Failure;

}

else

{

result = DTSExecResult.Success;

}

vars.Unlock();

return result;

The key thing here is that you're using the variableDispenser to lock the specific variable identified by the component's property, working with it, and then unlocking it when you're done.

(The SubComponent method which is referenced in the code sample above is just a little helper routine that returns a string in a standard format to identify where an error or event is coming from. I need this type of string in many places, so I have a function that can be reused, but it's not really relevant to your question...)

Hope this helps!

Wednesday, March 7, 2012

HELP!

Let's say I have a table similar to the one below:
ID Car Color
1 BMW silver
2 BMW silver
3 BMW red
4 BMW red
5 BMW red
Is it possible to group BMW, and count the colors in separate fields.
Car Silver Red
BMW 2 3
"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
If you have a known set of colours, then try
SELECT Car
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'silver' and v.Car = o.Car)
AS Silver
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'red' and v.Car = o.car)
AS Red
FROM vehicles AS o
GROUP BY Car
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004
|||"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
>
>
>
|||To create crosstabs both static (known number of pivot columns) and
dynamic (unknown number of pivot columns) without any complicated
sql coding check out the RAC utility for S2k.RAC is somewhat similar
to the Access crosstab but is much more powerful and has many
options.
RAC v2.2 and QALite @.
www.rac4sql.net
|||Bob, much thanks to you, the script works perfectly. I did have select within a select as you did, but you took it a step further using V and O. What is V and O by the way? Are they virtual fields?
-- Bob Simms wrote: --
"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> BMW 2 3
If you have a known set of colours, then try
SELECT Car
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'silver' and v.Car = o.Car)
AS Silver
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'red' and v.Car = o.car)
AS Red
FROM vehicles AS o
GROUP BY Car
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004
|||Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.server:338537
"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:3564FA65-B638-415B-9806-362D5A3C8581@.microsoft.com...
> Bob, much thanks to you, the script works perfectly. I did have select
within a select as you did, but you took it a step further using V and O.
What is V and O by the way? Are they virtual fields?
No, they are just aliases for the tables
FROM vehicles AS v
means that you can then refer to the vehicles table as v
Because we are referring to the vehicles table in the outer and inner SELECT
statements, we have to have give them different aliases so SQL knows which
one we are talking about.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004

Monday, February 27, 2012

Help!

Help,
i have a nt server sp6 with sql sp3 installed and configured by someone
else. in recent weeks our dc/exchange server had a similar problem in where
i had to do a reinstall from scratch and restore from backup.
because of user accounts being recreated i had to go and add the users again
on the sql server.
i decided to reboot the server after completing the task of adding the
users. then the fun began... the server will past the post, no problem, then
when the winnt server logo would appear on the screen with the mouse
cursor...wham the server started to reboot in an endless loop...right at the
same spot, the winnt logo screen and mouse cursor being displayed on the
screen.
I figured i post this here since this happened right after adding the users
in sql.
it looks like a virus at play but none was detected before the server was
rebooted.
has anybody seen this happen before?
can this configuration be saved ?
any help would be greatly appreciated.
thanks
ronaldHi ,
Ask your system administrater to try out this,
I am merely guessing, try this:
get to system using Console Repair Mode and then change
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wi
ndowsNT\CurrentVersion\Winlogon\Auto
AdminLogon to 0
also if that doesn't help, try to go to your %temp% folder and delete
sit*.tmp files, which the Readme says are used to store the passwords.
Thanks
Hari
MCDBA
"ronald" <ronald_padilla@.msn.com> wrote in message
news:ufR2qMIEEHA.3408@.tk2msftngp13.phx.gbl...
> Help,
> i have a nt server sp6 with sql sp3 installed and configured by someone
> else. in recent weeks our dc/exchange server had a similar problem in
where
> i had to do a reinstall from scratch and restore from backup.
> because of user accounts being recreated i had to go and add the users
again
> on the sql server.
> i decided to reboot the server after completing the task of adding the
> users. then the fun began... the server will past the post, no problem,
then
> when the winnt server logo would appear on the screen with the mouse
> cursor...wham the server started to reboot in an endless loop...right at
the
> same spot, the winnt logo screen and mouse cursor being displayed on the
> screen.
> I figured i post this here since this happened right after adding the
users
> in sql.
> it looks like a virus at play but none was detected before the server was
> rebooted.
> has anybody seen this happen before?
> can this configuration be saved ?
> any help would be greatly appreciated.
> thanks
> ronald
>|||thanks guys.
the server was configured with raid 5 and getting to the registry was a
problem. i needed a way to get to the sql data. i used a independant "hd"
from the raid 5 and was able to back up the data to then restore sql .
again thanks
ronald
"Hari" <hari_prasad_k@.hotmail.com> wrote in message
news:%23AOgoRJEEHA.3016@.TK2MSFTNGP11.phx.gbl...
> Hi ,
> Ask your system administrater to try out this,
> I am merely guessing, try this:
> get to system using Console Repair Mode and then change
>
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wi
ndowsNT\CurrentVersion\Winlogon\Auto[col
or=darkred]
> AdminLogon to 0
> also if that doesn't help, try to go to your %temp% folder and delete
> sit*.tmp files, which the Readme says are used to store the passwords.
> Thanks
> Hari
> MCDBA
>
> "ronald" <ronald_padilla@.msn.com> wrote in message
> news:ufR2qMIEEHA.3408@.tk2msftngp13.phx.gbl...
> where
> again
> then
> the
> users
was
>

HELP!

Let's say I have a table similar to the one below:
ID Car Color
1 BMW silver
2 BMW silver
3 BMW red
4 BMW red
5 BMW red
Is it possible to group BMW, and count the colors in separate fields.
Car Silver Red
BMW 2 3"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
If you have a known set of colours, then try
SELECT Car
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'silver' and v.Car = o.Car)
AS Silver
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'red' and v.Car = o.car)
AS Red
FROM vehicles AS o
GROUP BY Car
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004|||"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
>
>
>|||To create crosstabs both static (known number of pivot columns) and
dynamic (unknown number of pivot columns) without any complicated
sql coding check out the RAC utility for S2k.RAC is somewhat similar
to the Access crosstab but is much more powerful and has many
options.
RAC v2.2 and QALite @.
www.rac4sql.net|||Bob, much thanks to you, the script works perfectly. I did have select with
in a select as you did, but you took it a step further using V and O. What i
s V and O by the way? Are they virtual fields?
-- Bob Simms wrote: --
"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> BMW 2 3
If you have a known set of colours, then try
SELECT Car
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'silver' and v.Car = o.Car)
AS Silver
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'red' and v.Car = o.car)
AS Red
FROM vehicles AS o
GROUP BY Car
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004|||Xref: TK2MSFTNGP08.phx.gbl microsoft.public.sqlserver.server:338537
"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:3564FA65-B638-415B-9806-362D5A3C8581@.microsoft.com...
> Bob, much thanks to you, the script works perfectly. I did have select
within a select as you did, but you took it a step further using V and O.
What is V and O by the way? Are they virtual fields?
No, they are just aliases for the tables
FROM vehicles AS v
means that you can then refer to the vehicles table as v
Because we are referring to the vehicles table in the outer and inner SELECT
statements, we have to have give them different aliases so SQL knows which
one we are talking about.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004

HELP!

Let's say I have a table similar to the one below
ID Car Colo
1 BMW silve
2 BMW silve
3 BMW red
4 BMW re
5 BMW re
Is it possible to group BMW, and count the colors in separate fields
Car Silver Re
BMW 2"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
If you have a known set of colours, then try
SELECT Car
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'silver' and v.Car = o.Car)
AS Silver
, (SELECT COUNT(*)
FROM vehicles AS v
WHERE Colour = 'red' and v.Car = o.car)
AS Red
FROM vehicles AS o
GROUP BY Car
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.647 / Virus Database: 414 - Release Date: 29/03/2004|||"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:9533FD53-A616-438E-BB32-5559CA6B7DDC@.microsoft.com...
> Let's say I have a table similar to the one below:
> ID Car Color
> 1 BMW silver
> 2 BMW silver
> 3 BMW red
> 4 BMW red
> 5 BMW red
> Is it possible to group BMW, and count the colors in separate fields.
> Car Silver Red
> BMW 2 3
>
>
>|||To create crosstabs both static (known number of pivot columns) and
dynamic (unknown number of pivot columns) without any complicated
sql coding check out the RAC utility for S2k.RAC is somewhat similar
to the Access crosstab but is much more powerful and has many
options.
RAC v2.2 and QALite @.
www.rac4sql.net|||"Chambers" <anonymous@.discussions.microsoft.com> wrote in message
news:3564FA65-B638-415B-9806-362D5A3C8581@.microsoft.com...
> Bob, much thanks to you, the script works perfectly. I did have select
within a select as you did, but you took it a step further using V and O.
What is V and O by the way? Are they virtual fields?
No, they are just aliases for the tables
FROM vehicles AS v
means that you can then refer to the vehicles table as v
Because we are referring to the vehicles table in the outer and inner SELECT
statements, we have to have give them different aliases so SQL knows which
one we are talking about.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.655 / Virus Database: 420 - Release Date: 08/04/2004

Sunday, February 19, 2012

Help with UPDATE with SqlDataSource and a Repeater

Hi,

I have a repeater which i need to build editing capabilities into in a similar way as the GridView, just a little unsure how to tie it together. Ideally i would like to use a GridView as this would do all of the work for me however it looks like I need to go with the repeater due to the nested nature of the data I am working with.

What is the best way to go about updating the data source from within a repeater? I have already built the edit interface with some MultiViews in the Repeater control and handling the ItemCommand event, just not sure how to actually update the data source.

Can I still use the SqlDataSource wizard to generate all of the SQL for me? If so, within the ItemCommand event handler I have the data i want to update back to the database by using the FindControl method and retrieving the Text, but how do i get this data into the SqlDataSource object and update the database?

Are there any samples available which show how to update a datasource using a repeater?

Your help is much appreciated

trenyboy

Have you thought about using a DataList, this is halfway between the GridView and the Repeater, but it's certainly easier to work with :-)

Have a look at thissample for an example of DataList binding, and thisone for an example of updating.

|||

No, I hadn't up until now! I was using the repeater because I have nested data which I needed to appear as if it were part of the same table, hence I need to render the html myself, but I see the DataList will also allow for this!

Does the DataList have support for Edit/Update in a similar way as the GridView does with using the SqlDataSource wizard and no custom code (ASP.NET 2.0)? If not, what would be the advantage for using the DataList over the Repeater?

Thanks

|||I'm not sure what you mean by "nested data". If you could explain that a little better I'm sure someone could come up with a good solution for you. Is the nested data from the SQL Server, and you want to add some more columns on to it, or is the nested data something being generated by the ASP.NET application like in an array/list?|||By nested data I am referring to parent/child relationships. Ihave summary (parent) rows which contain one or more detail (child)rows. All rows need to look as though they are part of the sametable, however, the parent rows provide an option to show or hide allof its related child rows.

What I have done to get around this is to use one repeater for theparent data, and another repeater for the child data, this way I ammanually rendering the html as a single table, but I can show/hide thischild repeater via its visible property.

It is from SQL Server, and all i want to be able to do is provide anediting functionality to allow the user to update the underlyingdatasource from the interface.

Does this make more sense?|||

Yes it does. I've never done that myself, but perhaps someone else here has.

If it were me, I would use a query to return all the data I wanted in the order I wanted, then use the gridview, and write my own javascript to hide/show the child rows.

|||

trenyboy wrote:

Does the DataList have support for Edit/Update in a similar way as the GridView does with using the SqlDataSource wizard and no custom code (ASP.NET 2.0)? If not, what would be the advantage for using the DataList over the Repeater?

No it doesn't. What I've always done in the past is implement my DataList_UpdateCommand and simply call the update on the DataAdapter that is Filling the DataSet that backs up the DataList. Then you can use QueryBuilder to generate the Update for you.

In fact I'm starting to think I might be able to use an ObjectDataSource here, I may have to experiment a little :-)