Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 July 24th, 2006, 04:58 PM
Registered User
 
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default hai please solve my problem



 want to up load the image file in msaccess database.. i get error

// syntax error in INSERT INTO

dim data() as byte
If Trim(TextBox1.Text) = "" Then
MsgBox("please select a image")
Exit Sub
End If
Dim fs As New FileStream(Trim(TextBox1.Text), FileMode.Open, FileAccess.Read)
Data = New [Byte](fs.Length) {}
fs.Read(data, 0, fs.Length)
sSQL = "INSERT INTO image VALUES (data)"
dba.Execute(sSQL)
If Trim(TextBox1.Text) = "" Then
MsgBox("please select a image")
Exit Sub
End If
Dim fs As New FileStream(Trim(TextBox1.Text), FileMode.Open, FileAccess.Read)
Data = New [Byte](fs.Length) {}
fs.Read(data, 0, fs.Length)
sSQL = "INSERT INTO image VALUES (data)"
dba.Execute(sSQL)


 
Old July 26th, 2006, 09:06 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your sql statement is incorrect because it is literally being passed to Access as: INSERT INTO image VALUE(data). Which is incorrect.

Also you dont define a column where the data should be inserted (As i assume you have multiple columns in this table). So you would need to alter your INSERT to sometihng like INSERT INTO image(imageData) Values ([byte data here]).

The solution below may or may not work, I know that in .NET i have to set my query up a different way to pass byte data into it properly but you can try this:

sSQL = "INSERT INTO image([columnname]) VALUES(" & data &")"

hth

"The one language all programmers understand is profanity."





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help to solve problem PankajMishra XSLT 7 April 19th, 2007 08:27 AM
Will you please help me to solve this problem....? vis_kapadia Excel VBA 2 November 22nd, 2006 04:57 AM
Solve the problem chandan_tandon General .NET 0 October 4th, 2006 07:00 AM
HELP! Can anyone solve this problem? JoeR VB How-To 3 September 5th, 2006 09:56 AM
hai anjaneyulu1234 J2EE 0 November 30th, 2004 02:15 PM





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