?
Solved

The ConnectionString property has not been initialized.

Posted on 2011-03-12
5
Medium Priority
?
738 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 Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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