Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 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 April 29th, 2008, 11:24 AM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default uploading pics

I'm trying to upload some pics in vs2003 and this is my first time. I'm getting a error saying connection string not initialized. Can someone help me. Here's my code

 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("ConnectionStrin g")
        conn.Open()


        Dim command As SqlClient.SqlCommand = _
             New SqlClient.SqlCommand( _
                        "INSERT INTO tblImages (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()

 
Old April 29th, 2008, 12:45 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

Does the connectionstring variable exist in the web.config?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old April 29th, 2008, 01:02 PM
Authorized User
 
Join Date: Oct 2006
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is this what you're talking about?

mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"

 
Old April 29th, 2008, 01:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Well, you are seeking for a setting called ConnectionString. Nothing there looks like that..

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old April 29th, 2008, 01:54 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You need to be looking for something like this:

<appSettings>
  <add key="ConnectionString" value="[your connection string goes here]" />
</appSettings>

-Peter
peterlanoie.blog





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Before Uploading ashokparchuri General .NET 1 June 7th, 2005 07:17 AM
Problems with loading external pics into an IFrame nancy Classic ASP Databases 2 April 26th, 2005 10:33 AM
about uploading shine SQL Server ASP 1 June 5th, 2003 06:35 PM





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