Hi guys, I'm new here and in dire need of help for a problem that I've worked on hours.

I created a table 'tblProductCat' in the webform and wanted to populate the table with the code below:

Imports System.Data
Imports System.Data.SqlClient

Partial Class ProductCategories
    Inherits System.Web.UI.Page

    'Define DA and DS here
    Dim dataAdapter As New SqlDataAdapter
    Dim dataSet As New DataSet

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim pointer As Integer = 0

        Dim ConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\FitXdb.mdf;Integrated Security=True;User Instance=True"
        Dim connection As New SqlConnection(ConnectionString)


            'Assign table to dataAdapter at the start of 'Try'
            dataAdapter = New SqlDataAdapter("SELECT * FROM CATEGORY", connection)
            dataAdapter.Fill(dataSet, "Category")

            If dataSet.Tables("Category").Rows.Count <> 0 Then

                While pointer <= dataSet.Tables("Category").Rows.Count
                    Dim tr As New TableRow()
                    Dim tr2 As New TableRow()
                    Dim tr3 As New TableRow()
                    Dim tr4 As New TableRow()
                    'Create new tablerows

                    Dim tc As New TableCell()
                    Dim tc2 As New TableCell()
                    Dim tc3 As New TableCell()
                    Dim tc4 As New TableCell()
                    'Create new tablecells

                    Dim img As New Image()
                    Dim link As New HyperLink()
                    Dim label As New Label()

                    img.ImageUrl = dataSet.Tables("Category").Rows(pointer).Item(3)
                    'Add first row and first cell - image

                    link.Text = dataSet.Tables("Category").Rows(pointer).Item(1)
                    link.Style("Color") = "#99CCFF"
                    link.NavigateUrl = "~\ProductList.aspx?CategoryID=" & dataSet.Tables("Category").Rows(pointer).Item(0) & "&CategoryName=" & dataSet.Tables("Category").Rows(pointer).Item(1)
                    'send categoryID and categoryName as query strings to productList page
                    'Add second row and second cell - category link

                    label.Text = dataSet.Tables("Category").Rows(pointer).Item(2)
                    label.Style("Size") = "small"
                    'Add third row & third cell - category description

                    tc4.Text = "<br />"
                    'Add fourth row & fourth cell - add breakpoint


                    pointer = pointer + 1

                End While

            End If

        Catch ex As Exception
            MsgBox("Failed to connect to database", MsgBoxStyle.OkOnly)
        End Try


    End Sub

End Class

Here's the web.config file:

        <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\FitXdb.mdf;Integrated Security=True;User Instance=True"
            providerName="System.Data.SqlClient" />

The problem is I can't connect to the database. Yes, the database is there, and I've checked on the naming as well. I have no earthly idea what went wrong. At one point, the error message (in a long yellow box) that goes along the line of 'offline' and 'check your root directory for *something*' during browsing appeared.

I tried creating a gridview and ran it through a data source with the same connection string and it got populated.

Anyone knows what went wrong here?

As u already set that in web config file.u need to set only
dim con As string;

dim connections as new sqlConnection(con)

Actually I tried your method but that didn't work too. I then checked my database and realised that the image column does not have any value. I included the link to the image files and it worked.

Thanks anyway, really appreciate it