[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

The ConnectionString property has not been initialized.

Posted on 2011-03-12
5
Medium Priority
?
743 Views
Last Modified: 2012-05-11
Hi All I am trying to use the SqlDataSource to query a mysql db. I am using the following code


String connectionString = (String)ConfigurationSettings.AppSettings["mysqlConnectionString"];
        string oQRY =
               @"SELECT [ID], [username], [forename], [surname] FROM (select [ID], [username], [forename], [surname], row_number()over(order by t.[surname]) as [rn] from [users] as t where (([forename] + ' ' + [surname]) LIKE @filter)) as st where st.[rn] between @startIndex and @endIndex";

        SqlDataSource ds = new SqlDataSource(connectionString, oQRY);

        ds.SelectParameters.Clear();
        ds.SelectParameters.Add("filter", TypeCode.String, string.Format("%{0}%", e.Filter));
        ds.SelectParameters.Add("startIndex", TypeCode.Int64, (e.BeginIndex + 1).ToString());
        ds.SelectParameters.Add("endIndex", TypeCode.Int64, (e.EndIndex + 1).ToString());
        comboBox.DataSource = ds;
        comboBox.DataBind();

however I am getting the error The ConnectionString proprty has not been initialized. Any ideas why?

Matt
0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 35118328
Normally means that mysqlConnectionString doesn't exist in web.config.
0
 
LVL 9

Expert Comment

by:mayank_joshi
ID: 35121357
can you show your web.config file?
0
 

Author Comment

by:flynny
ID: 35123252
heres the connection string section from the web.config

      <connectionStrings>
            <add name="mysqlConnectionString" connectionString="Server=xxx;Database=xxx;User=xxx;Password=xxx" providerName="MySql.Data.MySqlClient"/>
      </connectionStrings>
0
 
LVL 9

Accepted Solution

by:
mayank_joshi earned 2000 total points
ID: 35126680
You are finding the connection string in AppSettings section while it is located in
ConnectionStrings section.

try:-
String ConnectionString=ConfigurationManager.ConnectionStrings("mysqlConnectionString").ConnectionString;

Open in new window

0
 

Author Closing Comment

by:flynny
ID: 35127338
duh sorry for being dumb.

thanks a bunch!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question