![]() |
Re: More SQL help needed
Any1 here know how to upload an image via an SQL connection onto a database held on SQL Server 2000? Any help would be very much appreciated. Here's the code I have so far:
Imports System.Data.SqlClient Imports System.IO PublicClass Form1 Inherits System.Windows.Forms.Form 'Declare a DataReader Object Private objDR As SqlDataReader PrivateSub Form1_Load(ByVal sender AsObject, ByVal e As System.EventArgs) HandlesMyBase.Load 'Open the SQLConnection object SqlConnection1.Open() 'Create the Datareader Object objDR = SqlCommand1.ExecuteReader() EndSub UPLOAD BUTTON CODE PrivateSub Upload_Button_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Upload_Button.Click Dim SQLreturn AsInteger Dim fsimage As System.IO.FileStream = New System.IO.FileStream(File_TextBox.Text, System.IO.FileMode.Open, System.IO.FileAccess.Read) Dim Picture(fsimage.Length) AsByte fsimage.Read(Picture, 0, fsimage.Length) Try SqlConnection1.Open() SqlCommand1.Parameters("@pictureTitle").Value = File_TextBox.Text SqlCommand1.Parameters("@pictureDescription").Valu e = DescriptionBox.Text SqlCommand1.Parameters("@pictureOwner").Value = System.Environment.UserName SqlCommand1.Parameters("@pictureData").Value = Picture SQLreturn = SqlCommand1.ExecuteNonQuery() 'command Catch ex As Exception MessageBox.Show(ex.Message) Finally SqlConnection1.Close() EndTry If SQLreturn <> 1 Then MessageBox.Show("Could not execute the INSERT query") 'results Else MessageBox.Show("INSERT completed successfully") EndIf File_TextBox.Clear() EndSub |
| All times are GMT. The time now is 17:45. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum