#1
  1. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2007
    Posts
    93
    Rep Power
    12

    Exclamation SQL Connection using web.config


    hi... the attach img is my error..
    and following is my code:

    Code:
     Dim connection As SqlConnection
            Dim strCon As String
            Dim sqlcmd As SqlCommand
    Dim builder As New StringBuilder
            builder.Append("INSERT INTO Profile ")
            builder.Append("(")
            builder.Append("name,")
            builder.Append("userid,")
            builder.Append("password,")
            builder.Append("gender,")
            builder.Append("email,")
            builder.Append("birthDate,")
            builder.Append("contact")
            builder.Append(") ")
            builder.Append("VALUES ")
            builder.Append("(")
            builder.Append("'" & name.Text & "', ")
            builder.Append("'" & username.Text & "',")
            builder.Append(("'" & pass1.Text & "', "))
            builder.Append(("'" & gender.Text & "', "))
            builder.Append(("'" & email.Text & "', "))
            builder.Append(("'" & birth.Text & "', "))
            builder.Append(("'" & contact.Text & "'"))
            builder.Append(") ")
     strCon = ConfigurationManager.AppSettings("ConnectionString")
            connection = New SqlConnection(strCon)
            sqlcmd = New SqlCommand(builder.ToString, connection)
            connection.Open()
          sqlcmd.ExecuteNonQuery()
    i m trying to get the pre defined connection string that is in my web.config file of my website..
    Attached Images
  2. #2
  3. Couch Potato Wizard
    ASP Mastermind (5000+ posts)

    Join Date
    Jan 2005
    Location
    India
    Posts
    13,651
    Rep Power
    2688
    Instead of this
    Code:
    strCon = ConfigurationManager.AppSettings("ConnectionString")
    try this
    Code:
    strCon = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
    If it still does not work, then post the connection code from web.config (without the username, password, etc..)

    Comments on this post

    • nofriends agrees
    Laziness is my religion and Sunday is my God

    Get the Mantra!
  4. #3
  5. No Profile Picture
    Contributing User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2007
    Posts
    93
    Rep Power
    12
    oh... thx man... it works
  6. #4
  7. Couch Potato Wizard
    ASP Mastermind (5000+ posts)

    Join Date
    Jan 2005
    Location
    India
    Posts
    13,651
    Rep Power
    2688
    Originally Posted by bczm8703
    oh... thx man... it works
    Glad i could help

Similar Threads

  1. Not associated with a trusted SQL Server connection.
    By MizDove in forum Microsoft SQL Server
    Replies: 2
    Last Post: March 25th, 2007, 12:29 AM
  2. 2 '80004005' errors
    By desiboy681 in forum Microsoft Access Help
    Replies: 2
    Last Post: November 15th, 2006, 12:27 PM
  3. Object required: '' Error???
    By miniskirt in forum ASP Development
    Replies: 15
    Last Post: July 3rd, 2006, 02:21 AM
  4. Need help with asp Sql problem
    By bleutiger in forum Programming Help
    Replies: 1
    Last Post: January 22nd, 2005, 10:44 PM
  5. Need help with ASP SQL Problem
    By bleutiger in forum ASP Development
    Replies: 1
    Last Post: January 20th, 2005, 12:13 PM

IMN logo majestic logo threadwatch logo seochat tools logo