473,394 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Transfer the Image Stored in a .gif File to an Image Column in a SQL Server Table

I am trying to use images in my web form and I am trying to write thie executable to help transfer the gifs into the SQL column. Here is my code, I am getting an error. All help is appreciated. Thanks in advance.
-----------------------------------------------------------------------------------------
Dim connString1 As String = ConfigurationSettings.AppSettings("connString1") 'bkf-sql1/jHelp
Dim cnnConnection As New System.Data.SqlClient.SqlConnection(connString1)
Dim rs As ADODB.Recordset
Dim mstream As ADODB.Stream
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
connString1 = ConfigurationSettings.AppSettings("connString1") 'bkf-sql1/jHelp
cnnConnection.Open()

rs = New ADODB.Recordset
rs.Open("Select Mag_Image from MagDirect_List", cnnConnection, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)

mstream = New ADODB.Stream
mstream.Type = ADODB.StreamTypeEnum.adTypeBinary
mstream.Open()
mstream.LoadFromFile("<C:\Inetpub\wwwroot\Magazine Direct\Magbmps>")
rs.Fields("MD_Image").Value = mstream.Read
rs.Update()

rs.Close()
cnnConnection.Close()
__________________________________________________ ____________________________
Error:
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Source Error:
Line 32:
Line 33: rs = New ADODB.Recordset
Line 34: rs.Open("Select Mag_Image from MagDirect_List", cnnConnection, ADODB.LockTypeEnum.adLockOptimistic, ADODB.CursorTypeEnum.adOpenKeyset)
Line 35:
Line 36: mstream = New ADODB.Stream
Jul 21 '05 #1
0 1270

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: vedwards | last post by:
I am trying to use images in my web form and I am trying to write thie executable to help transfer the gifs into the SQL column. Here is my code, I am getting an error. All help is appreciated....
9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: Lyle Fairfield | last post by:
I created a new MS-SQL Database, "TestODBC". I made Table1 and StoredProcedure1. I made an ODBC DSN for that MS-SQL Database. I created a new AccessXP mdb, "TestODBC". I linked to the...
10
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
8
by: yoyo | last post by:
Ok, I think I just may be a moron, but where the heck are the Image extenders found? I've look all around, tried all the DB2 cd's I have, are they installed by default somewhere? Which install...
2
by: satish | last post by:
hi, i have inserted the image present in mydocuments using alter command create table aa(a int, d image) insert into aa values (1,'F:\prudhvi\baba 002.jpg') when i do select * from aa i...
1
by: manmit.walia | last post by:
Hello All, I am stuck on a task that I need to complete. What I have is a SQL 2005 DB running with a Table called Docs. The table structure consists of the following: Table Structure for Docs...
3
by: itarunachalam | last post by:
Hi friends, I have a table structure like this in SQL sever 2000. i want a stored procedure to transfer the data from "tblSurvey" table to "tblRespondent" table. Table - tblSurvey...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.