467,888 Members | 1,586 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,888 developers. It's quick & easy.

sqldatasource problems

Hi!

Did anyone successfully managed to use some custom ADO.NET
provider with SqlDataSource? I'd like to connect to some
other database than MSSQL (like MySQL, Firebird or PostgreSQL)
but I'm having problems making this work.
Inside connectionStrings I added my name, provider and
connectionString but for some reason SqlDataSource is trying
to use System.Data.SqlClient even if my provider is
different.

Also I tried registering my provider in machine.config but it
won't show up in VS.

Any help would be appreciated.
Nov 23 '05 #1
  • viewed: 4723
Share:
3 Replies
what driver did you specify in the connect string?

-- bruce (sqlwork.com)

"zapov" <za***@yahoo.com> wrote in message
news:dm**********@news1.xnet.hr...
Hi!

Did anyone successfully managed to use some custom ADO.NET
provider with SqlDataSource? I'd like to connect to some
other database than MSSQL (like MySQL, Firebird or PostgreSQL)
but I'm having problems making this work.
Inside connectionStrings I added my name, provider and
connectionString but for some reason SqlDataSource is trying
to use System.Data.SqlClient even if my provider is
different.

Also I tried registering my provider in machine.config but it
won't show up in VS.

Any help would be appreciated.

Nov 23 '05 #2
Bruce Barker wrote:
what driver did you specify in the connect string?


I'm using PostgreSQL driver.
In Web.config I added
<add name="postgres" connectionString="server=localhost;User
id=postgres;Password=1234;database=proba;Encoding= Unicode"
providerName="Npgsql" />

And in aspx file I have
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:postgres %>"
SelectCommand="select * from table"></asp:SqlDataSource>

But, when I try to run it I get
Keyword not supported: 'encoding'.
because ASP is trying to use System.Data.SqlClient
[ArgumentException: Keyword not supported: 'encoding'.]
System.Data.Common.DbConnectionOptions.ParseIntern al(Hashtable
parsetable, String connectionString, Boolean buildChain, Hashtable
synonyms, Boolean firstKey) +263
System.Data.Common.DbConnectionOptions..ctor(Strin g
connectionString, Hashtable synonyms, Boolean useOdbcRules) +129
System.Data.SqlClient.SqlConnectionString..ctor(St ring
connectionString) +116

System.Data.SqlClient.SqlConnectionFactory.CreateC onnectionOptions(String
connectionString, DbConnectionOptions previous) +46

System.Data.ProviderBase.DbConnectionFactory.GetCo nnectionPoolGroup(String
connectionString, DbConnectionPoolGroupOptions poolOptions,
DbConnectionOptions& userConnectionOptions) +201
System.Data.SqlClient.SqlConnection.ConnectionStri ng_Set(String
value) +82
System.Data.SqlClient.SqlConnection.set_Connection String(String
value) +28
System.Web.UI.WebControls.SqlDataSource.CreateConn ection(String
connectionString) +63

System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments
arguments) +215
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments
arguments, DataSourceViewSelectCallback callback) +84
System.Web.UI.WebControls.DataBoundControl.Perform Select() +154
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +99
System.Web.UI.WebControls.GridView.DataBind() +24
Nov 23 '05 #3
zapov wrote:
Bruce Barker wrote:
what driver did you specify in the connect string?


I'm using PostgreSQL driver.
In Web.config I added
<add name="postgres" connectionString="server=localhost;User
id=postgres;Password=1234;database=proba;Encoding= Unicode"
providerName="Npgsql" />

And in aspx file I have
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:postgres %>"
SelectCommand="select * from table"></asp:SqlDataSource>


Also, when I change SqlDataSource to
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:postgres %>"
ProviderName="<%$ ConnectionStrings:postgres.providerName %>"
SelectCommand="select * from bugs.bugs"></asp:SqlDataSource>

I receive
Failed to find or load the registered .Net Framework Data Provider.

[ConfigurationErrorsException: Failed to find or load the registered
..Net Framework Data Provider.]
System.Data.Common.DbProviderFactories.GetFactory( DataRow
providerRow) +371
System.Data.Common.DbProviderFactories.GetFactory( String
providerInvariantName) +138
System.Web.UI.WebControls.SqlDataSource.GetDbProvi derFactory() +64
System.Web.UI.WebControls.SqlDataSource.GetDbProvi derFactorySecure() +51
System.Web.UI.WebControls.SqlDataSource.CreateConn ection(String
connectionString) +37
Ok, I get it. ASP can't find registered DbProviderFactory
But, I have in machine.config under <DbProviderFactories>
<add name="PostgreSQL Data Provider" invariant="Npgsql"
description=".Net Framework Data Provider for PostgreSQL"
type="Npgsql.NpgsqlFactory, System.Data, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" />

And as I understand this should enable it to be displayed in VS
but it isn't.

So, I am wondering is there anything special that should be
implemented in ADO.NET provider so it could be used in SqlDataSource?
Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Martin Bischoff | last post: by
reply views Thread by Alain Hogue | last post: by
2 posts views Thread by stuart.d.jones | last post: by
reply views Thread by Camel | last post: by
3 posts views Thread by Daniel R. H. | last post: by
9 posts views Thread by Dan Sikorsky | last post: by
2 posts views Thread by djc | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.