Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Value of type 'String' cannot be converted to 'System.Data.SqlClient.S

Status
Not open for further replies.

takwirira

Programmer
Mar 6, 2007
23
GB
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
 
This would probably get more timely answers if it were posted in the VB.NET/VB2005 forum796
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top