Im am getting the error above Value of type 'String' cannot be converted to 'System.Data.SqlClient.SqlConnection' when I try to execute the code to populate a GridView on the website with the query shown below. Any ideas why ?
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
LoadData()
End Sub
Private Function LoadData() As DataView
Dim ds As DataSet = New DataSet
Dim cmdSelect As New SqlCommand
Dim da As SqlDataAdapter = New SqlDataAdapter
cmdSelect.CommandText = "Select Name from Runners WHERE Name LIKE 'T%'"
cmdSelect.Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\runnersdb.mdb" - this bit is underlined as the problem
da.SelectCommand = cmdSelect
da.Fill(ds)
LoadData = ds.Tables(0).DefaultView
GridView1.DataSource = LoadData()
GridView1.DataBind()
End Function
End Class
Imports System.Data
Imports System.Data.SqlClient
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
LoadData()
End Sub
Private Function LoadData() As DataView
Dim ds As DataSet = New DataSet
Dim cmdSelect As New SqlCommand
Dim da As SqlDataAdapter = New SqlDataAdapter
cmdSelect.CommandText = "Select Name from Runners WHERE Name LIKE 'T%'"
cmdSelect.Connection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\runnersdb.mdb" - this bit is underlined as the problem
da.SelectCommand = cmdSelect
da.Fill(ds)
LoadData = ds.Tables(0).DefaultView
GridView1.DataSource = LoadData()
GridView1.DataBind()
End Function
End Class