Link to home
Create AccountLog in
ASP.NET

ASP.NET

--

Questions

--

Followers

Top Experts

Avatar of ddrhoward
ddrhoward

Pictures not loading
I have a html file that loads the pictures, but whenever I'm step thru my code, it throws up the error....
Connection string not properly initialized.. And truthfully I don't know what to do.
Dim fileName As String
        Dim fileType As String
        Dim namePosition As Int16
        Dim stream As IO.Stream
        Dim conn As New SqlClient.SqlConnection
        Dim Cmd As SqlClient.SqlCommand
 
 
        stream = file1.PostedFile.InputStream
        Dim uploadedFile(stream.Length) As Byte
 
        stream.Read(uploadedFile, 0, stream.Length)
 
        namePosition = file1.PostedFile.FileName.LastIndexOf("\") + 1
        fileName = file1.PostedFile.FileName.Substring(namePosition)
        fileType = file1.PostedFile.ContentType
 
 
        conn.ConnectionString = _
               ConfigurationSettings.AppSettings("ConnectionString")
        conn.Open()
 
 
        Dim command As SqlClient.SqlCommand = _
             New SqlClient.SqlCommand( _
                        "INSERT INTO tblFFImages (vchDescription, vchimage, vchcasenumber)Values(@vchdescription, @vchimage, @vchcasenumber", conn)
 
        command.Parameters.Add _
                ("@vchDescription", _
                SqlDbType.Text).Value = txtdescription.Text
 
        command.Parameters.Add _
                ("@vchcasenumber", _
                SqlDbType.Int).Value = txtcasenumber.Text
 
        command.Parameters.Add _
                ("@vchimage", _
                SqlDbType.Image, uploadedFile.Length).Value = uploadedFile
 
        command.ExecuteNonQuery()
        conn.Close()

Open in new window

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


ASKER CERTIFIED SOLUTION
Avatar of ssjo22ssjo22🇨🇦

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

SOLUTION
Avatar of Bob LearnedBob Learned🇺🇸

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

Avatar of ddrhowardddrhoward

ASKER

I was able tofind a solution.  I used a stored procedure instead.   But thanks for your help.
 connFF = New SqlConnection(Application("connFF"))
               Dim cmdLoad As SqlCommand = New SqlCommand("spFFLoadImages", connFF)
        cmdLoad.CommandType = CommandType.StoredProcedure
 
        Dim fileName As String
        Dim fileType As String
        Dim namePosition As Int16
        Dim stream As IO.Stream
 
 
        stream = file1.PostedFile.InputStream
        Dim uploadedFile(stream.Length) As Byte
        stream.Read(uploadedFile, 0, stream.Length)
 
        namePosition = file1.PostedFile.FileName.LastIndexOf("\") + 1
        fileName = file1.PostedFile.FileName.Substring(namePosition)
        fileType = file1.PostedFile.ContentType
 
 
            If strcasenumber <> "" Then
                CheckDuplicateCaseNumber()
                If intcount >= 1 Then
                    lblmessage.Visible = True
                    lblmessage.Text = "Report Notes have been previously submitted for casenumber " + strcasenumber + "."
                    Exit Sub
                End If
            End If
 
            connFF.Open()
            With cmdNotes.Parameters
                .Add("@reportdate", dtreportdate)
                .Add("@DSFM", strDSFM)
                .Add("@casenumber", strcasenumber)
                .Add("@county", strcounty)
                .Add("@Notes", strnotes)
                .Add("@status", strstatus)
                .Add("@description", strdescription)
                .Add("@image", uploadedFile)
            End With

Open in new window


Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.

ASP.NET

ASP.NET

--

Questions

--

Followers

Top Experts

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications