Help with this Argument 'Prompt' cannot be converted to type 'Stri
Hi;
I am creating a windows app using ado.net 2.0 in the app I am connecting to
a database by creating and then using a data provider factory.
When I call sqlConn.Open() I get the follwoing message "Argument 'Prompt -
cannot be converted to type String".
What am I missing in my code ?
My code follows:
Here are the entries in my app.config file
<configuration>
<appSettings>
<add key="provider" value="System.Data.SqlClient" />
</appSettings>
<connectionStrings>
<add name ="cnStr" connectionString =
"Data Source=aServer;integrated Security=True;initial Catalog=GoodTable" />
</connectionStrings>
</configuration>
Here is how I call this in my app. :
Try
Dim sAttr As String = ConfigurationManager.AppSettings("provider")
' Dim dp As DataProvider =
CType(Enum].Parse(GetType(DataProvider),sAttr), DataProvider)
Dim cnStr As String =
ConfigurationManager.ConnectionStrings("cnStr").ConnectionString
' Create the provider factory
Dim df As DbProviderFactory =
DbProviderFactories.GetFactory(sAttr)
'Connection here
Dim sqlConn As DbConnection = df.CreateConnection()
sqlConn.ConnectionString = cnStr
Catch ex As Exception
MsgBox(ex)
End Try
Try
sqlConn.Open()
Catch ex1 As Exception
MsgBox(ex1)
End Try
Thanks for any suggestions !
--
Gordon
Date:Tue, 17 Jul 2007 13:08:02 -0700
Author:
|