Click here to Skip to main content
15,894,540 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error on this page
VB
Dim result As Integer = cmd.ExecuteNonQuery()




VB
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim strImageName As String = txtname.Text.ToString()

        If FileUpload1.PostedFile IsNot Nothing AndAlso FileUpload1.PostedFile.FileName <> "" Then

            Dim imageSize(FileUpload1.PostedFile.ContentLength - 1) As Byte
            Dim uploadedImage_1 As HttpPostedFile = FileUpload1.PostedFile
            uploadedImage_1.InputStream.Read(imageSize, 0, CInt(FileUpload1.PostedFile.ContentLength))
            Dim con As New SqlConnection("user id=sa;password=siva;Initial Catalog=Travel;server=192.168.90.9")
            Dim cmd As New SqlCommand
            cmd.CommandText = "insert into image(imageID, imageName, Image)values (@imageID ,@imageName,@image)"
            cmd.CommandType = CommandType.Text
            cmd.Connection = con
            Dim Imageid As New SqlParameter("@imageID", SqlDbType.Int)
            cmd.Parameters.Add(Imageid)
            Dim ImageName As New SqlParameter("@imageName", SqlDbType.VarChar, 50)
            ImageName.Value = strImageName.ToString()
            cmd.Parameters.Add(ImageName)

            Dim UploadedImage__2 As New SqlParameter("@image", SqlDbType.Image, imageSize.Length)
            UploadedImage__2.Value = imageSize
            cmd.Parameters.Add(UploadedImage__2)
            con.Open()
            Dim result As Integer = cmd.ExecuteNonQuery()
            con.Close()
            If result > 0 Then
                Label2.Text = "File Uploaded"
            End If
            GridView1.DataBind()
        End If


    End Sub
End Class


this is my program
Posted

You've put it in, but you've not given it a value. It is therefore 'not supplied'.
 
Share this answer
 
Comments
amperayani 2-Aug-12 2:52am    
thank you
Hi,
Here is what you are using to add @imageID parameter.
VB
Dim Imageid As New SqlParameter("@imageID", SqlDbType.Int)
cmd.Parameters.Add(Imageid)



But where are you adding the value for it?
Try adding the value. Your problem will be solved.


--Amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900