Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 23rd, 2005, 02:07 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inserting & Retrieving Images on Sql Server

Hi
The guros
I am using VB.net with Sql server to add images in to the table.
This is how I did it but could not work:

mycommand.commandtext = "INSERT INTO student_master" & _
                        " ( st_picture, st_signature)" & _
                        " values ( @picture1, @picture2)" & _
                        " where student_id = @stu_id"
mycommand.parameters.add( "@picture1", picturebox1.image)
mycommand.parameters.add( "@picture2", picturebox2.image)
mycommand.parameters.add( "@stud_id", txtstudent_id.text)

I also tried EXEC SP_tableoption student_master, 'txt In row', 'ON'
on the table and executed the above code again; but did not work

I also tried UPDATE statement instead of INSERT statement, but still can not work.

I also need some help to retrieve images from table on to the forms of Vb.net

Adamu sufi :)


 
Old June 23rd, 2005, 05:30 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Adamu,

First, your INSERT statement will create a new row in the student_master table, UPDATE will update an EXISTING row in the table.

Second, what is the data type of the column in which you are attempting to insert the image? This is important.

Third, take a look at the topic of BLOB in the Visual Studio help.

Let me know if this helps. If you need further assistance, let me know.

Scott

 
Old June 24th, 2005, 03:50 AM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Scott

The data type is image.
Look at the way I use the INSERT i used where student_id = @stu_id" which means it will be for an existing record. The 2 images field are empty. The Student_master table contains alot of other fields that data have been inserted through forms. If figure out how to insert the image I can change it to UPDATE statement if that does not work.

 
Old June 24th, 2005, 07:51 AM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Adamu,

The INSERT statement creates ("Inserts") NEW rows into the table. If you want to update an EXISTING record, you need to use the UPDATE statement.

UPDATE student_master SET st_picture = @picture1, st_signature = @picture2" & _
                        " where student_id = @stu_id"

mycommand.parameters.add( "@picture1", picturebox1.image)
mycommand.parameters.add( "@picture2", picturebox2.image)
mycommand.parameters.add( "@stud_id", txtstudent_id.text)

Scott

 
Old June 24th, 2005, 02:43 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Scott

 I did it the same way, but it gave error, so I did it this way

Dim xpict as Image
Dim xsign as Image

xpict = pictureBox.Image
xsign = pictureBox.Image

UPDATE student_master SET st_picture = "xpict", st_signature = "xsign" & _
          " where student_id = @stu_id"

mycommand.parameters.add("@stud_id",txtstudent_id. text)


This one seems to have worked. To me there is no difference between the 2 codes. I dont't know why the other one works and the other one did not work.

The problem is to comfirm on the table whether it really updated. I looked at the table and is showing me binary on the image fields. I tried crystal Report to disply the field but I did not see it displayed. Do have an idea how to display Image from the table ?

Adamu




 
Old June 24th, 2005, 08:34 PM
SQLScott's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 338
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Hi Adamu,

I am glad you were successful in getting the Update to work. As far as getting the image to display it in Crysal reports, i am not a Crystal expert so I really do not know how to do it. However, we have a few people who use it at work and i can ask them. Another option is to check on their support web site http://support.businessobjects.com/ and see if they have anything to help you out. I am sure they do. I will check at work and if I find anything I will certainly let you know.

Scott

 
Old June 26th, 2005, 03:32 PM
Registered User
 
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Scott

I comfirmed, it has updated through this Sql stament i.e

SELECT student_id FROM student_master WHERE
picture1 IS NOT NULL.

It only showed me the record I updated.
I will really appreciate if you can check for me from the people who work on crystal report.
I am also going to create Dataset and Dataview using VB. Net to see how it can display images on VB.Net
application. I am also going to check the site you gave me on the crystal reports objects. Thanks alot.

Adamu






Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing & retrieving swf file from sql server tarduk2004 ASP.NET 2.0 Basics 2 October 30th, 2007 02:31 AM
update& retrieval of images from sql server.. preetham.sarojavenkatesh ASP.NET 2.0 Basics 5 August 7th, 2007 12:07 PM
Retrieving Images from SQL Server jazzcatone ASP.NET 1.0 and 1.1 Professional 1 September 19th, 2006 11:33 AM
inserting images in ms sql server using query anal connect2sandep SQL Server 2000 2 July 24th, 2005 04:41 PM
Inserting Images and retrieving from SQL SERVER adamusufi VB.NET 2002/2003 Basics 0 June 24th, 2005 04:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.