Showing posts with label rows. Show all posts
Showing posts with label rows. Show all posts

Monday, March 19, 2012

Mysteriously dropped rows using Data Flow Task

I'm using the Data Flow Task to load data from a flat file into a SQL table and I'm missing rows. And there doesn't see to be any consistent or obvious reason why.

When I use the Bulk Insert Task I import the correct number of rows from the flat file. But when I use the Data Flow task and use a Flat File Source connected to a OLE DB Destination I get about 1/3 the right number of rows. So looking at these loaded tables at the same time I notice that the Data Flow Task method just skips rows sometimes.

Why does this happen?

Try to enable error output and redirect the error output to a different table and see if any rows are sent there.

Hope this helps,

Ovidiu Burlacu

|||

just for people looking around; this issue got addres in other post: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=884012&SiteID=1

Rafael Salas

Wednesday, March 7, 2012

MyDataTable.NewRow() - Looping issue

Code:

DataRow dr;foreach (object chkedin chklst.CheckedItems)

{

dr = qrequest.NewRow();

dr = queries.Tables[0].Rows.Find(chked);

qrequest.Rows.Add(dr);

}

it makes it through the loop once just fine but when it goes around for time number 2 it says the object is already in the table. I cant really say i know what im doing here, but i do (sort of) understand why its doing this. the question is, how do i get around this?

I actually got this code from MSDN (they used a for loop and added multiple rows to a table just like this)

Thanks

Justin

You should try declaring your row inside the for loop; that way the variable is initialized during each cycle. Otherwise, the row still holds the reference to the last row (which you just added to the table).

foreach (object chkedin chklst.CheckedItems) {DataRow dr; dr = qrequest.NewRow();dr = queries.Tables[0].Rows.Find(chked);qrequest.Rows.Add(dr);}

Also, is qrequest empty to begin with? If it has any of the rows that are returned from queries.Tables(0).Rows.Find() then that will cause a redundancy error. But mostly I think your issue is what I described above.

|||

I actually tried that and i got the same error, did it ever so slightly different, did the declare as one line: DataRow dr = new DataRow();

i cant realy imagine thats any different than what you did but it still gave me the same error.

|||

Hi,

I'm not quite sure what you're trying to do. But there are some problems in the code.

1. The dr = qrequest.NewRow(); line will have no use because the next line points dr to the other DataRow instance.
2. The found row already belongs to a certain table and it cannot be added to another DataTable. In this case, you will need to use ImportRow() method instead.

|||

yeah my biggest problem was #2. which is i guess a direct result of #1. either way i did find a way around it but i must have over looked the importrow which is exactly what i need.

If i dont define columns for the table im importing to does it create them automatically based on the row im importing?

Thanks

Justin

|||

No, Justin. We can only import rows according to the current schema.

HTH. If this does not answer you question, please feel free to mark it as Not Answered and post your reply. Thanks!

Saturday, February 25, 2012

My report wont work :-) with a date param

Hi All,
I have inherited a report that at the Dataset level works fine. It takes a
date param eg. 02-Dec-2005 and returns 3 rows as I would expect.
The report page has the date param defined as Datetime and when I enter the
date ie. 02-Dec-2005 it returns 0 rows. I have tried inputting different date
formats
to no avail. kinda puzzled.
Any clues as to the cause of the problem.
Thanx in advancewell,i had kind of this problem.
I never use parm as datetime always as string and inside the dataset i use
CONVERT(datetime,@.FromTime,103) it works 4 me...
"Scotchy" wrote:
> Hi All,
> I have inherited a report that at the Dataset level works fine. It takes a
> date param eg. 02-Dec-2005 and returns 3 rows as I would expect.
> The report page has the date param defined as Datetime and when I enter the
> date ie. 02-Dec-2005 it returns 0 rows. I have tried inputting different date
> formats
> to no avail. kinda puzzled.
> Any clues as to the cause of the problem.
> Thanx in advance
>|||It sounds to me like your query parameter is not hooked up to your report
parameter. In the dataset click on the ..., parameters tab. Your query
parameters should be listed on the left and the report parameter they map to
on the right.
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"Scotchy" <Scotchy@.discussions.microsoft.com> wrote in message
news:B64FE999-9EA6-40C0-896E-984BBDC4BDC4@.microsoft.com...
> Hi All,
> I have inherited a report that at the Dataset level works fine. It takes a
> date param eg. 02-Dec-2005 and returns 3 rows as I would expect.
> The report page has the date param defined as Datetime and when I enter
> the
> date ie. 02-Dec-2005 it returns 0 rows. I have tried inputting different
> date
> formats
> to no avail. kinda puzzled.
> Any clues as to the cause of the problem.
> Thanx in advance
>|||Thanks Bruse, but no, all params are mapped as required. Something else going
on here I think, might try a string param instead , although Ive not had this
issue before in Date param'd reps. Guess thats the problem when inheriting
others work. Thanx for your and others input. Much appreciated
"Bruce L-C [MVP]" wrote:
> It sounds to me like your query parameter is not hooked up to your report
> parameter. In the dataset click on the ..., parameters tab. Your query
> parameters should be listed on the left and the report parameter they map to
> on the right.
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "Scotchy" <Scotchy@.discussions.microsoft.com> wrote in message
> news:B64FE999-9EA6-40C0-896E-984BBDC4BDC4@.microsoft.com...
> > Hi All,
> >
> > I have inherited a report that at the Dataset level works fine. It takes a
> > date param eg. 02-Dec-2005 and returns 3 rows as I would expect.
> >
> > The report page has the date param defined as Datetime and when I enter
> > the
> > date ie. 02-Dec-2005 it returns 0 rows. I have tried inputting different
> > date
> > formats
> > to no avail. kinda puzzled.
> >
> > Any clues as to the cause of the problem.
> >
> > Thanx in advance
> >
>
>

Monday, February 20, 2012

My Query is broken and I don't know how to fix it...

I am trying to set up a filtered paging ObjectDataSource for a gridvoew control.

My code works, my query doesn't...

This is OK: Get all rows of data:
"SELECT UCO, country_code, country_name, enabled, concurrency FROM CountryCodes "
Returns all records as expected

This is OK: Getting rows of data with no Filter:
"SELECT UCO, country_code, country_name, enabled, concurrency FROM (SELECT ROW_NUMBER() OVER (ORDER BY country_name ) As Row, UCO, country_code, country_name, enabled, concurrency FROM CountryCodes ) As TempRowTable WHERE Row >= 0 AND Row <= 10"
Returns expected data

This is OK: Making sure my WHERE filter works:
"SELECT UCO, country_code, country_name, enabled, concurrency FROM CountryCodes WHERE country_name LIKE '%u%' "
Returns 85 records

This is BROKEN!!!: I want to return 10 rows of filtered data:
"SELECT UCO, country_code, country_name, enabled, concurrency FROM (SELECT ROW_NUMBER() OVER (ORDER BY country_name ) As Row, UCO, country_code, country_name, enabled, concurrency FROM CountryCodes ) As TempRowTable WHERE ( Row >= 0 AND Row <= 10 ) AND ( country_name LIKE '%u%' ) "
It Returns 0 records!!!

What am I doing wrong in the last query?
Or even better how do I fix it?

Thanks,
Roger

Why don't you just do SELECT TOP 10 UCO,...|||

if you don't want use top 10.

The problem is that your where clause needs to be in the derived table.

SELECT UCO, country_code, country_name, enabled, concurrency FROM (SELECT ROW_NUMBER() OVER (ORDER BY country_name ) As Row, UCO, country_code, country_name, enabled, concurrency FROM CountryCodes WHERE country_name LIKE '%u%') As TempRowTable WHERE ( Row >= 0 AND Row <= 10 )

|||

You will have to post a repro script demonstrating the problem. There is nothing wrong with your query. And it is more efficient using the TOP clause in this case to get the top 10 rows instead of using ROW_NUMBER and then filtering on it.

|||Roger,

Your query is most likely working as it should - it should

return 0 rows, given your data, I believe, since you asked

for those rows with country_name like '%u%' that appear in

the first 10 rows of CountryCodes (ordered by country_name).

Apparently none of the first 10 rows have country_name values

like '%u%'.

If you wanted the first 10 rows with country_name like '%u%',

you can either change the problem Ryan noticed (shown here

using a similar query from the AdventureWorks sample database).

select

FirstName, LastName

from (

select

FirstName, LastName,

row_number() over (order by ContactID) as row

from Person.Contact

where LastName like '%x%'

) as C

where row > 0 and row <= 10

go

or use Ryan's and Anith's suggestion of TOP:

select top (10)

FirstName, LastName

from Person.Contact

where LastName like '%x%'

order by ContactID

Note that a query like yours will return no rows here

as well:

select

FirstName, LastName

from (

select

FirstName, LastName,

row_number() over (order by ContactID) as row

from Person.Contact

) as C

where LastName like '%x%'

and row > 0 and row <= 10

go

Steve Kass

Drew University

rogerw@.discussions.microsoft.com wrote:

> I am trying to set up a filtered paging ObjectDataSource for a gridvoew

> control.

>

> My code works, my query doesn't...

>

> This is OK: Get all rows of data:

> "SELECT UCO, country_code, country_name, enabled, concurrency FROM

> CountryCodes "

> Returns all records as expected

>

> This is OK: Getting rows of data with no Filter:

> "SELECT UCO, country_code, country_name, enabled, concurrency FROM

> (SELECT ROW_NUMBER() OVER (ORDER BY country_name ) As Row, UCO,

> country_code, country_name, enabled, concurrency FROM CountryCodes ) As

> TempRowTable WHERE Row >= 0 AND Row <= 10"

> Returns expected data

>

> This is OK: Making sure my WHERE filter works:

> "SELECT UCO, country_code, country_name, enabled, concurrency FROM

> CountryCodes WHERE country_name LIKE '%u%' "

> Returns 85 records

>

> This is BROKEN!!!: I want to return 10 rows of filtered data:

> "SELECT UCO, country_code, country_name, enabled, concurrency FROM

> (SELECT ROW_NUMBER() OVER (ORDER BY country_name ) As Row, UCO,

> country_code, country_name, enabled, concurrency FROM CountryCodes ) As

> TempRowTable WHERE ( Row >= 0 AND Row <= 10 ) AND ( country_name LIKE

> '%u%' ) "

> It Returns 0 records!!!

>

> What am I doing wrong in the last query?

> Or even better how do I fix it?

>

> Thanks,

> Roger

>

>|||

Duh - I thought I had tried that. Must be a clear case of tunnel vision.

Thanks for the help,
Roger

My Products table

hello,

i have a Products table, and i want to make an image data type to one of his rows (Picture1 for example), i want to know, what is best, to store the picture in the database or store only the direction to the picture?

if i store only the direction, i should take it from some output parameters of the Upload function of ASP and the add it to the Database? can i add it to a special folder for example MySite\UserName\ + file name?

and another thing: let's say i have Promotion - tinyint, to store the promotion value of this product..If i show products using DataList, i could order my products first after Promotion and then after date added? could i use a special CssClass(font weight or other background) for the products witch has the Promotion more than 10 for example?

how can i know the exact date time (yy/mm/dd/hh/mm) ? - it is taked from the Server date?

thank you

Have a look at

http://www.codeproject.com/aspnet/PicManager.asp|||

Hi zuperboy90,

i have a Products table, and i want to make an image data type to one of his rows (Picture1 for example), i want to know, what is best, to store the picture in the database or store only the direction to the picture?

if i store only the direction, i should take it from some output parameters of the Upload function of ASP and the add it to the Database? can i add it to a special folder for example MySite\UserName\ + file name?

Well, it depends. If your image file size is very large on everage, I would suggest you using sql database to store the link and using a file server to store the actual image file. Actually it's not too dificult to impliment. Using asp.net update control to store the image file to a specific folder, and pass the path(with the file name) to your backend database.

If your image file is not a big one,then just create a new field named "image" with type "binary(SIZE)", and fill this field using a stream writer. This is a very conveninet way if you only want to store some icon/thumbnail pictures.

There are lots of sample articles on this, just type "picture gallery asp.net" into google and you will find millions of resources.

Hope my suggestion helps

|||

for a wile i store in my database only the link to the pictures (they are very many, and hight resolution), and i think i'll use something like ImageUrl = <%# Eval("url") %>, i don't know exacly how it will be, i'll se if it is ok when implementing the code that alowes you to add pictures, and then chose the best way

thank you