Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:00:55+00:00 2026-06-09T23:00:55+00:00

I built a dataset using the wizzard and added a connection in there. I

  • 0

I built a dataset using the wizzard and added a connection in there.

I now want to use a connection string which is defined in my web config instead of whats set in the dataset.

I have the following code (i’ve taken a lot of stuff out you don’t need to see)

Partial Public Class downloaditems
Inherits System.Web.UI.Page

Private dtmboFeed As dsmbo.mboFeedDataTable
Private tamboFeed As New dsmboTableAdapters.mboFeedTableAdapter
Private itemCount As Integer = 0
Private changedItem As Boolean = False
Private headSource As String
Private footSource As String
Private sideSource As String
Private lastHead As String
Private lastFoot As String
Private lastSide As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    feedChecks()
    If changedItem = True Then
        If itemCount = "3" Then
            savetodatabase(headSource, footSource, sideSource)
        End If
    End If
End Sub

Private Sub checkSite(ByVal URL As String, ByVal Type As String)

    Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URL)
    request.UserAgent = ".NET Framework Test Client"
    Dim response As System.Net.HttpWebResponse = request.GetResponse()

    Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

    Dim sourcecode As String = sr.ReadToEnd()
    Dim compareHead As Integer
    Dim compareFoot As Integer
    Dim compareSide As Integer

    Select Case Type
        Case "headSource"
            headSource = sourcecode
            compareHead = String.Compare(headSource, lastHead)
        Case "footSource"
            footSource = sourcecode
            compareFoot = String.Compare(footSource, lastFoot)
        Case "sideSource"
            sideSource = sourcecode
            compareSide = String.Compare(sideSource, lastSide)
    End Select

    If Not compareHead = "0" Then
        changedItem = True
    End If
    If Not compareFoot = "0" Then
        changedItem = True
    End If
    If Not compareSide = "0" Then
        changedItem = True
    End If

    itemCount = itemCount + 1

End Sub

Private Sub feedChecks()

    Dim lastImport As DateTime
    dtmboFeed = New dsmbo.mboFeedDataTable
    dtmboFeed = tamboFeed.GetCode()

    For Each rFeed As dsmbo.mboFeedRow In dtmboFeed
        lastImport = rFeed.LastImport
        lastHead = rFeed.HeaderCode
        lastFoot = rFeed.FooterCode
        lastSide = rFeed.SideCode
    Next

    If lastImport > System.DateTime.Now.AddDays(1) Then
        checkSite("http://www.xxx.me/sss/header.html", "headSource")
        checkSite("http://www.xxx.me/sss/footer.html", "footSource")
        checkSite("http://www.xxx.me/sss/sidenav.html", "sideSource")
    Else
        Exit Sub
    End If


End Sub

Private Sub savetodatabase(ByVal HeaderCode As String, ByVal FooterCode As String, ByVal SideCode As String)

    dtmboFeed = tamboFeed.GetData()
    Dim rFeed As dsmbo.mboFeedRow

    rFeed = dtmboFeed.NewmboFeedRow

    rFeed.HeaderCode = HeaderCode
    rFeed.FooterCode = FooterCode
    rFeed.SideCode = SideCode
    rFeed.LastImport = System.DateTime.Now
    rFeed.Verified = "True"

    dtmboFeed.AddmboFeedRow(rFeed)
    tamboFeed.Update(dtmboFeed)

    lblCode.Text = lblCode.Text & "All downloaded"

End Sub End Class

EDIT:

Heres my updated code below as requested. I’m getting an error saying

Error   53  Value of type 'String' cannot be converted to 'System.Data.SqlClient.SqlConnection'.

Code:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim constring As String
        constring = ConfigurationManager.ConnectionStrings("ConnectString").ToString()
        tamboFeed.Connection = constring

        feedChecks()
        If changedItem = True Then
            If itemCount = "3" Then
                savetodatabase(headSource, footSource, sideSource)
            End If
        End If
    End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:00:56+00:00Added an answer on June 9, 2026 at 11:00 pm

    You can get the connection string as

    Dim constring as String
    constring = ConfigurationManager.ConnectionStrings("YouconnectionStringNameinWebConfig").ConnectionString
    

    Now first go to your DataSet Design View, Select the table,right click on tableAdapter and Change it’s Connection modifier to Public ( see below picture ), now you can access adapter connection property in the codebehind.

    tamboFeed.Connection = constring 
    

    See the below picture for changing access modifier.enter image description here

    Picture Reference: Link

    Updated answer:
    The problem is that you have placed you connection string in the AppSettings section in the webconfig, add your connection string to ConnectionString Section. See below code

        <connectionStrings>     
    <add  name="ConnectString" connectionString="data source=server;initial catalog=database;persist security info=False;user id=adsadasda;password=asdsadasd;packet size=4096" />
     </connectionStrings>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using web service built in .net in which I want to return
I want to build a dataset consisting about 2000-3000 web pages, starting with several
We built a iphone app and now we would like to export it to
I built the opencl program using the commands: gcc -c -I ~/AMDAPP/include main.c -o
I built my app using Grails 2.0.4 and tested it in Jetty. In Jetty
Well, the problem is as follows: I have a WPF Application built using the
I'm trying to test my DAO layer (which is built on JPA) in separation.
I have the below SQL Script which is run from Excel VBA using ADO
I'm using ASP.NET to build a form which has 3 DropDownLists and one GridView.
Using: ASP.NET 4, SQL 2008, C# I'm writing a web app for our projects

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.