sql connection string in web.config trouble

G

Guest

Please, anyone who has experience setting up a sql connection string in the
web.config file, can you decipher this error.:

Keyword not supported: 'datasource'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported:
'datasource'.

Source Error:


Line 44: Dim connstrng As String
Line 45: connstrng =
ConfigurationSettings.AppSettings("MediaConnstring")
Line 46: Dim cnMedia As New SqlConnection(connstrng)
Line 47: Dim dsMedia As DataSet
Line 48: Dim daMedia As New SqlDataAdapter("select * from
media_all", cnMedia)


Source File: c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb Line: 46

Stack Trace:


[ArgumentException: Keyword not supported: 'datasource'.]
System.Data.Common.DBConnectionString.ParseInternal(Char[]
connectionString, UdlSupport checkForUdl, NameValuePair& keychain) +1133
System.Data.Common.DBConnectionString..ctor(String connectionString,
UdlSupport checkForUdl) +114
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
+13
System.Data.SqlClient.SqlConnectionString.ParseString(String
connectionString) +96
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +11
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +158
MediaApp.MediaGrid2.DisplayData() in
c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb:46
MediaApp.MediaGrid2.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb:36
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
 
J

John Spiegel

What is the connection string you're trying to retrieve from the config?
First guess: try adding a space... 'data source'
 
G

Guest

Hi,
The following is a sample Connection string.
Have a look at it and do ncecessary changes to your string.
"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
Hope it works.
Happy Coding

John Spiegel said:
What is the connection string you're trying to retrieve from the config?
First guess: try adding a space... 'data source'
syhart said:
Please, anyone who has experience setting up a sql connection string in
the
web.config file, can you decipher this error.:

Keyword not supported: 'datasource'.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.ArgumentException: Keyword not supported:
'datasource'.

Source Error:


Line 44: Dim connstrng As String
Line 45: connstrng =
ConfigurationSettings.AppSettings("MediaConnstring")
Line 46: Dim cnMedia As New SqlConnection(connstrng)
Line 47: Dim dsMedia As DataSet
Line 48: Dim daMedia As New SqlDataAdapter("select * from
media_all", cnMedia)


Source File: c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb Line: 46

Stack Trace:


[ArgumentException: Keyword not supported: 'datasource'.]
System.Data.Common.DBConnectionString.ParseInternal(Char[]
connectionString, UdlSupport checkForUdl, NameValuePair& keychain) +1133
System.Data.Common.DBConnectionString..ctor(String connectionString,
UdlSupport checkForUdl) +114
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
+13
System.Data.SqlClient.SqlConnectionString.ParseString(String
connectionString) +96
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
+11
System.Data.SqlClient.SqlConnection..ctor(String connectionString) +158
MediaApp.MediaGrid2.DisplayData() in
c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb:46
MediaApp.MediaGrid2.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\MediaApp\MediaGrid2.aspx.vb:36
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
 
G

Guest

Thanks. After closer examination the string was formatted incorrectly. You
have to be careful to write the connection string exactly as it should appear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top