Showing posts with label display. Show all posts
Showing posts with label display. Show all posts

Thursday, March 29, 2012

duplicated data display

Hi all. i have the following function below,which use to retrieve the order detail from 2 table which are order detail and product. i have many duplicated order id in order detail, and each order id has a unique product id which link to product to display the product information. however when i run the following function below . its duplicated each product info and dsplay in the combo box. May i know whats wrong with my code?

Public Sub ProductShow()

Dim myReader As SqlCeDataReader
Dim mySqlCommand As SqlCeCommand
Dim myCommandBehavior As New CommandBehavior
Try
connLocal.Open()
mySqlCommand = New SqlCeCommand
mySqlCommand = connLocal.CreateCommand
mySqlCommand.CommandText = "SELECT * FROM Product P,orders O,orderdetail OD WHERE OD.O_Id='" & [Global].O_Id & "' AND P.P_Id=OD.P_Id "
myCommandBehavior = CommandBehavior.CloseConnection
myReader = mySqlCommand.ExecuteReader(myCommandBehavior)
While (myReader.Read())
cboProductPurchased.Items.Add(myReader("P_Name").ToString())
End While
myReader.Close()
Catch ex As Exception
MsgBox(ex.ToString)
Finally
connLocal.Close()
End Try

End Sub

Can you please provide sample data also?

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

Tuesday, March 27, 2012

duplicate rows - how to?

I have first_name field and i want to display duplicated rows only, i mean when the same exact name was there more than one time, like John and John...

Code Snippet

select first_name

from MyTable

groupby first_name

havingcount(*)>1

|||

Try:

select first_name

from dbo.t1

group by first_name

having count(*) > 1

AMB

|||

Using SQL Server 2005,

Code Snippet

;With CTE

as

(

Select First_Name,Row_Number() OVER (Partition By First_Name Order By First_Name) RowId From Table

)

Select Distinct First_Name from CTE Where RowId > 1

Thursday, March 22, 2012

Duplicate display of values in the Details section

Hi folks,

i have a peculiar problem, i am passing a query from VB 6.0 to crystal reports to revieve the data i want and i am successful in doing that. But the problem is, it is
duplicating the output, i'm seeking for. it duplicates when the output is places in the Details section but when i place it in the Header section then there is no duplication.
can any one please tell me why?

thanx in advance.......

number3I hope I've understood the question correctly...

How many rows is your query returning? The details section is the only section that creates a new section for every row returned by the query. If you drag the field into the header you are only going to get the value from the first row. This is how crystal is supposed to work.

If you need a second details section (from another result set), you need to look at placing a subreport in the header.|||you need to run your SQL in a database viewer tool. possibly you have linked some tables together but not put a criteria in the select expert..

you CAN choose "select distinct records" on the database menu, but this will make the report run more slowly. you should really fix up your sql so it doesnt return you duplicatessql

Sunday, March 11, 2012

dublicate records

I am trying to display records based on item_id and discription. But problem is, one item_id has more than one Discriptions but I want to display only one item_id with its discription. Distinct is not working because each record is different. Can I get only one record for each item? table structure is

item_no int,
desc varchar(80)

Any help will be highly appreciated.You will need some sort of business logic to decide which description you want to display when multiple descriptions are available. First alphabetically? Longest? Last entered?|||I need first description.

thanks for prompt reply|||SELECT item_no, MIN(Desc) AS MIN_Desc
FROM yourTable99
WHERE intem+no = @.item_no
GROUP BY item_no|||First description?

First how?

Alphabetically (as Brett's example)?

First entered?

First among equals?

Women and children first?

There is no "first" description, except as defined by you.|||Thanks Brett, it worked|||First description?

First how?

Alphabetically (as Brett's example)?

First entered?

First among equals?

Women and children first?

There is no "first" description, except as defined by you.

Don't you just hate Access|||Nah. FIRST() and LAST() are useful functions. But lately I've been jumping back and forth between Access, SQL Server, and Oracle, sometimes several times each day, and it always takes a minute or two to change hats. That is a real pain.|||OK, so how does Access know what FIRST() and LAST() is?

I should profiler that ans see what it does...

Betcha it returns all the rows of the result set, and in it's own convoluted way, determines by the order the result set comes back in...even tjough it could be different every time...

Betcha|||I think it is like the TOP clause in SQL, where it uses the order defined by the query. If no order supplied, than all bets are off, of course.

By the way, I tried using ROWNUM in Oracle to return the first 10 rows of an ordered query, like TOP in SQL. No go. The ROWNUM value is applied BEFORE the sort! Had to enclose the sorted set in a subquery and then wrap it in a shell for selecting based on ROWNUM. Sucks.|||Every Row in Oracle gets enumerated, so it is an actual "pointer" to that specific row...Oracle is all about pointers to the data...

Have you used the reference cursors yet?|||Yeah. Had to.

Friday, February 24, 2012

DTS: EXCEL TO SQL: Returns an empty recodset

Hi there,

I use Asp.Net Application to upload a Excel file and then a DTS to import data from the file to the SQL2000 and finally to display the read data on the screen.

The DTS starts with setting some variables with the help of Dynamic properties.
On Succes.
DTS rum 2 simultaneous Transform Data task importing data from excel to SQL2000.

This works fine for "most" of the time, but then there are the other times.
One of the TDT(Transform Data task) reads nothing from the excel file. but it can read the data if i upload the same file again right after.

Any kind of input is welcome

Thanx
/bs26Originally posted by bs26
Hi there,

I use Asp.Net Application to upload a Excel file and then a DTS to import data from the file to the SQL2000 and finally to display the read data on the screen.

The DTS starts with setting some variables with the help of Dynamic properties.
On Succes.
DTS rum 2 simultaneous Transform Data task importing data from excel to SQL2000.

This works fine for "most" of the time, but then there are the other times.
One of the TDT(Transform Data task) reads nothing from the excel file. but it can read the data if i upload the same file again right after.

Any kind of input is welcome

Thanx
/bs26

It sounds as if you are experiencing a locking problem with the two Transform Data tasks. I have had similar problems with importing and exporting to Access databases.

Try it with only one TDT and see if it fixes it.

If you need the additional speed of multiple TDT's, you might try splitting up or duplicating the data over several excel workbooks.