Showing posts with label mssql. Show all posts
Showing posts with label mssql. Show all posts

Sunday, March 25, 2012

DISTINCT query issue

I'm familiar with MySQL and recently started working with MSSQL.
I have a general understanding of how the DISTINCT command works, but would like to expand on that a bit.

I need to do a DISTINCT query on a record's 'name' column, but i need all of the values for each of those returned records. So, I need the query to only apply the DISTINCT command to the 'name' column, not the other columns of the received records.

Can someone explain a bit how to word this

Many thanks in advance.

EDIT: Upon reflection, I realize now that this request is counter to the way DISTINCT works. D'oh. Move along, nothing to see here. :(

Hi,

As you have wrote at the end of your message, you can not get such a list.

But if you want to get records of having same specific column value, you can run a select and order by over that column also can add a criteria to filter returned data.

Wednesday, March 21, 2012

Distinct

Hi, I've recently moved a site to MSSQL server from Access and I've hit a few problems as it implements SQL differently. I've had a lot of duplicate data on the site which I have partly remedied by using SELECT DISTINCT - though I don't know how to use this in conjunction with SELECT * to cure other parts of my site that return duplicate data. Does anyone know how to do this? Thanks!First let mi say that MSSQL Server supports most(if not all) of the sql u write in Ms Access; it however builds on this to provide proprietary utility aggregate functions using T-SQL...
So depending on ur calling application(front end)...use 'select distinct' in ur SQL cmd to get distinct record temporarily or u just go 2 d database to do dat - select distinct into a temporary table, delete d table n insert d distinct records into a new table dat bears d name of the old(deleted) table.|||ok thanks, i'll look into that.

Like above because of syntax differences, this no longer works and the page does not display:

"Select * from Events where Format(EventDate,'yyyymmdd') >= " & FormatDate(Now(),"YYYYMMDD") & " order by EventDate asc"

I'm pretty sure it has something to do with Format(), but I'm a little unsure. Any ideas?

Thanks!|||u cannot use an expression directly on the column name, so try:
"Select * from Events where EventDate >= " & FormatDate(Now(),"YYYYMMDD") & " order by EventDate asc"|||hmm still not working|||use convert function of sql serversql

Friday, February 17, 2012

Display image to ASP .NET from bynary data MSSQL 2000

Hi I have image in database sql server 2000 and want to display in ASP .net page. I make the memorystream from that data and write directly to page using Response.Write([bynary stream]) but U know it only display one image and other HTML is gone.

Normaly a HTML or ASP.net page will display image using local files like this <img src=..........> but how if I want to display it from memory stream that doesn't have physically in storage ? Or should I save that binary to storage first and then reference it ?

So anyone that have solution for this problem please help me how to this thing .........Smile

Hi, Take a lok at the MSDN articles on images and bitmaps.

http://msdn2.microsoft.com/en-us/library/a343dky2.aspx

regards

smcoxon

|||

You don't understand. I'm not ask about image !

My question is how to display a binary image in memorystream to ASP.NET page via HTTP ?

I try to directly write by HttpResponse.Write( ... ) but U know it display the image only......

What I want is this image can be displayed in ASP.net page ......, I can't use <img src='.......'> ,

because it's on memory stream not in URL format or in local file in your hard drive.

|||

Hi,

smcoxon has given part of the answer but that is related to winforms. The picture box can accept the byte stream that you get from the binary datatype you stored the image in.

For aspx pages.

You have to first create a page which just serves the images.

so your image tag would be

<img src="http://pics.10026.com/?src=YourImageServingPage.aspx?imageID=1" ...

On YourImageServingPage.aspx

You would remove all mark up and then add this to your code behind

Response.Clear();
Response.ContentType="image/jpeg"; or any image type you are serving.

You would create a BitMap class load your bytes from database and write the image to the Response.Write stream.

You would find many articles on this Search Key: dynamic image generation

Happy programming,
Anton

Display image in Crystal Report 10

I have to generate a report containing data and images in the database, e.g. product information + product image (kept as "image" type in MSSQL database). The information and images are kept in one table named "ProductInfo". The no. of images may vary depending on user input, e.g. on-shelf date. The expected output of the report is similar to below:

<<image1>>
Item: ABC Shampoo
Product No.: 1111

<<image2>>
Item: XXX Toothpaste
Product No.: 2222

<<image3>>
Item: YYY Shaver
Product No.: 3333

User will input the date range in a VB form and a Crystal Report Preview will show the output. I am currently using VB.NET 2003, Crystal Report 10, MSSQL 2000. Would you please help? Thanks very much.

Regards,Store image path in database field, then use picture box in detail section to display pictures.

U can use graphic location property in format editor of picture box...