Populating TreeView Control using Access Database
Here is a little information that might be of value in helping solve my problem.
1). I am using the SQLDatasource object to connect to an access database. I am writing this web app to basically replace a manual my organization using concerning services we offer. What I am trying to achieve is to display an index using a TreeView Control to categorize the various services we offer alphabetically. First I want to show a list of nodes from A to Z. When the use clicks the plus sign by the A I want a dropdown list of all the services that begin with A to display. Like wise if the user clicks Z I want all the services to display that begin with Z. Then once the list of services for the corresponding alphabet are displayed I want the user to be able to click the service and then I will display a text box containing detailed information about the service.
Here is my dilemma. I run my web app and my program gives me an error 'System.Data.OleDb.OleDbConnection' cannot be converted to 'String'. Here is the code where the error happens.
Dim mySource As SqlDataSource = New SqlDataSource(conn, "GetIndexes")
a.) conn is my connection string in my web.config file. The code in my web.config file looks like this
<appSettings>
<add key="conn" value="Provider = Microsoft.Jet.OLEDB.4.0;Data So urce=C:\Documents
and Settings\ronald.rex\Desktop\GuideToCityServices.md b;User ID=Admin;Password=;" />
</appSettings>
b.) GetIndexes is a Stored Procedure in my Database
Also do you see any problems with the code block below, in particular the line.
Dim result As IEnumerable = mySource.Select(DataSourceSelectArguments.Empty)
I was making changes to my code last night I received an error saying that âThe Provider does not recognize Argumentâ and according to the compiler the problem was with Ienumerable.
Public Shared Function GetIndexes() As CategoryList
Dim categories As New CategoryList
Dim conn As OleDbConnection = New OleDbConnection System.Configuration.ConfigurationManager.AppSetti ngs("conn"))
'Dim connStr As String = ConfigurationManager.ConnectionStrings("conn").Con nectionString
Dim mySource As SqlDataSource = New SqlDataSource(conn, "GetIndexes")
mySource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure
Dim result As IEnumerable = mySource.Select(DataSourceSelectArguments.Empty)
Dim row As DataRowView
For Each row In result
categories.Add(New Category( _
row("Id").ToString(), _
row("Index").ToString()) _
)
Next
Return categories
End Function
|