Connection Strings and MySQL

I usually connect to mysql in code:

myConnection = New MySqlConnection 

 But I am trying to learn how to use web.config connection strings

<connectionStrings> 

<add name=ConnString" connectionString="Server=;Port=3306;Database=;Uid=;Pwd=;pooling=false;" providerName="MySql.Data.MySqlClient"  />

</connectionStrings>

and the aspx.vb code:

  myConnection = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString

 

But I get the following error..

BC30311: Value of type 'System.Configuration.ConnectionStringSettingsCollection' cannot be converted to 'MySql.Data.MySqlClient.MySqlConnection'.



Any help anyone thanks...

Lost.... 

0
lostandconfused
4/20/2009 6:31:07 PM
asp.net.mysql 1929 articles. 0 followers. Follow

6 Replies
725 Views

Similar Articles

[PageSpeed] 33

 Try these:

http://forums.crystaltech.com/index.php?topic=34040.0

 

http://forums.asp.net/p/1403209/3043706.aspx


"Hokey religions and ancient weapons are no match for a good blaster at your side."
0
DarthSwian
4/20/2009 6:49:39 PM

It looks like a type cast problem to me....try something like below.

myConnection = New OdbcConnection(ConfigurationManager.ConnectionStrings["ConnString"])

Basically what i want you to try is typecasting the connection string to ODBC connection object.


Thanks,
Surya Prakash Jayanti
http://suryaprakashj.blogspot.com
http://jnsuryaprakash.blogspot.com
http://sqlserver-qa.net/blogs/dotnet_40/default.aspx

p.s. Please click "Mark as Answer" if you think this post answered your question
0
jnsuryaprakash
4/20/2009 6:51:31 PM

myConnection is an instance of the MySqlConnection class. A connectionstring is a string, Therefore...

myConnection=New MySqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString)


-- "Mark As Answer" if my reply helped you --
0
gunteman
4/20/2009 6:54:43 PM

DarthSwian:

 Try these:

http://forums.crystaltech.com/index.php?topic=34040.0

 

http://forums.asp.net/p/1403209/3043706.aspx

These are inline solutions which works fine I do not want Inline I want Web.Config connection string

The inline is 

myConnection = New MySqlConnection("Server=;Port=;Database=;Uid=;Pwd=;") 

and works fine but this is not what I want so if Update the password I don't have to change it 100 times.. 

 

jnsuryaprakash:

It looks like a type cast problem to me....try something like below.

myConnection = New OdbcConnection(ConfigurationManager.ConnectionStrings["ConnString"])

Basically what i want you to try is typecasting the connection string to ODBC connection object.

I am not using Odbc I am using mysql .net connector

 

gunteman:

myConnection is an instance of the MySqlConnection class. A connectionstring is a string, Therefore...

myConnection=New MySqlConnection(ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString)


 I now get this error message:

BC30108: 'MySqlConnection' is a type and cannot be used as an expression.

 

Anyone got ideas thanks... 

0
lostandconfused
4/20/2009 8:49:45 PM

The answer is:

 

 myConnection = New MySqlConnection(ConfigurationManager.ConnectionStrings("connString").ConnectionString)

 why didn't guntenman's post work well [] don't work () do  all because of brakets..
 

Thanks for the help. 

0
lostandconfused
4/21/2009 6:17:33 PM

Are you familiar with the MySqlHelper class? You can use it to execute dataSets, dataReaders and more, I mainly use it for those two types tho. It saves on a lot of code, you could use it like this:

Dim sConn as String = ConfigurationManager.ConnectionStrings("connString").ConnectionString
Dim sSQL as String = "SELECT * FROM some_table"
Dim myRdr as MySqlDataReader
myRdr = MySqlHelper.ExecuteReader(sConn, sSQL)
If myRdr.HasRows Then
'Do Something
End If
myRdr.Close

Doing this takes advantage of connection pooling while letting MySQL manage it, the only thing you must remember is to close your DataReader. Hope this helps.

0
baileyswalk
5/1/2009 11:13:54 AM
Reply:

Similar Artilces:

ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'IP Address of the server'(10048) ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'IP of the server' (10
Hi, I am randomly getting the following error message in my application. ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'IP Address of the server'(10048) ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'IP of the server' (10048) I am using .Net 2.0 with VS2005 having ODBC 3.51.14 Driver.  Can any body point out the core reasons of the above error message? Thanks. Nouman Khawaja. I do have the same problem, help me out. Thanks  If the going seems easy, You are going DownHill... When I was writing ...

MySQL
Currently have a site coded in PHP but the customer wants to go to .NET. Can I use the existing MySQL DB or am I required to use MSSQL? Thanks, Ken Check out this forum which is specialized for this kind of questions: ASP.NET MySQL forumBart De Smet [MVP] Visit www.msdn.be, www.bartdesmet.net...

mySQL connection string
Hi. I just want to know how to connect to a mySQL server from an ASP.NET page. Here are the informations I have: Host: mysql.mydns.com Port: 3306 UserID : myID Password : myPassword Database Name : myDB Wich connection string should I use? Is there anoyone who can help me? Do You use a managed provider like dbProvider? If! you use dbProvider (I use the Personal version) do like this (can recomend it, works like a glance): '## -- Connection string to a mySQL Database -- Dim ConnectionString As String = "Data Source=localhost;Database=...

Connection String for MySQL
I have seen many queries about MySQL but i have been struggling to find a connection string to perform a connection to MySQL on my Web Host. Appreciate if you can let me know the connection string. Many Thanks. http://www.connectionstrings.com/Gunnar Peipman-- General Protection Fault-- Illegal Page Fault-- Not My Fault Why don't you use "MySQL Connector/Net" ? Find information in here : http://www.mysql.com/products/connector/net/ Basic connection string using mySql 4.17 and .Net Connector 1.02 or above. You can add addition parameters for IP, Port etc Checkout o...

Connection String with MySql
Hi, When we want to use Connection string without username password in Sql Server we write the connection string like below <connectionStrings> <add name="ConnectionString" connectionString="Data Source=localhost;Initial Catalog=Glad;User ID=Nutri_User;Password=123;" providerName="System.Data.SqlClient" /> </connectionStrings> How can we use this in the MySql <connectionStrings> <add name="ConnectionString" connectionString="Data Source=localhost;Initial Catalog=Glad;User ID=Nutri_User;Password=123;" provid...

mysql connection string
ok ive been building asp .net websites in vs studio with ms sql server butt as thats so exspensive to host have decided to change to mysql but not shure on the connection string Web.config file ___________________________________________________________________ <appSettings> <add key="ConnectionString" Data Source=UniversityHelp; Database=UniversityHelp; /> </appSettings> _______________________________________________________________________ my.ini file ________________________________________________________________________ [my...

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Hi, I get the error when I try to connect.. :o(( What's wrong? TIA, Juan. ...

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.soc
2 day old install of 11.3; I installed MYSQL from yast2; 12 items relating to MYSQL are shown as installed; on a command line (as root) I get "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysql/mysql.soc" when I type MYSQL. Another problem ; Apache is installed and running, but my install of PHP from Yast has been troubled, and very much unlike what I read here : "http://www.novell.com/coolsolutions/feature/595.html" ; a web page with phpinfo() shows nothing; do I have to do another manual config of LAMP ? If so wh...

Segmentation fault while connecting to mysql through DBD::Mysql
Hi All, When I try to connect to mysql db through perl dbd, get segmentation fault error. attached DBI trace report. Any help on this is appreciated. Name "main::dbwritesallowed" used only once: possible typo at ./t.pl line 14. DBI 1.15-nothread dispatch trace level set to 5 -> DBI->connect(DBI:mysql:host=localhost;database=bugs;port=3306, bugs, ****) -> DBI->install_driver(mysql) for perl=5.008003 pid=2777 ruid=0 euid=0 install_driver: DBD::mysql loaded (version 2.9002) New DBI::dr (for DBD::mysql::dr, parent=, id=) dbih_...

Newbie: DBD::mysql error connecting to mysql
I'm new to Bugzilla, Apache, mysql, and perl (whew) and am trying to get Bugzilla 2.18 up and running... I've been banging my head on a problem for a few hours and seem to be stuck... I am at the point where checksetup.pl runs cleanly. I can connect to the system from a browser on a client workstation and get the initial Bugzilla screen without errors. When I navigate to some of the other screens, such as "Enter a new bug report" I am faced with a "Software Error" that seems to indicate perl is having trouble connecting to mysql. Any help is appreciate...

Connection String for mysql #2
 Hi all,        In my local server connection string working fine. The code is <appSettings>              <add key="connection string" value=" Driver={MySQL ODBC 3.51 Driver};Server=192.168.1.46;Port=3306;Database=jobportal;Uid=root;Pwd=root;"/>    </appSettings>When  host it is not working. shows the  following errorERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified  Download and inst...

Connecting to MySQL from VS.Net
I can connect to SQL server in VS.Net, but I cannot get to connect to my remote MySQL server. It would be great if I could use the same UI to admin the two server. Anyone know how I can do this ?...

Connect String (MySql remotely)
Hi all, I uploaded MySQL database to the server and server info is:   Server version: 4.0.26 Protocol version: 10 Server: mysql7 (216.157.145.47 via TCP/IP) User: wswebsi_admin@216.157.146.2 The connect string I am using is <add name="MySQLConnectionString" connectionString="server=216.157.145.47 ; user id=wswebsi_admin@216.157.146.2; password=***; database=wswebsi_test; pooling=false; " providerName="MySql.Data.MySqlClient"/>   But it doesnt work, I dont know why, can you help me plz...urgent:)  Thanks Try looking at this ...

mySQL connection string #2
Hello, I need to connect to a mySQL database from my ASP .NET project. I have two questions first though that I need to know: #1. Can I just use ODBC objects to access the mySQL database? #2. What should my connection string look like for the database? Thanks!! Yes, you can use ODBC (specifically ODBC.NET) to connect to MySQL. Be sure you have MyODBC and ODBC.NET installed on your computer. Possible connection strings: # ODBC 2.50 Local database: "Driver={mySQL};Server=localhost;Option=16834;Database=mydatabase;" # ODBC 2.50 Remote database: "Dr...

Web resources about - Connection Strings and MySQL - asp.net.mysql

Connection - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

iMedia Connection: Interactive Marketing News, Features, Podcasts and Video - iMediaConnection.com
If you send more email, you might make more money. Then again, you might destroy your reputation and revenue stream. Here's how to know what ...

HTTP persistent connection - Wikipedia, the free encyclopedia
... tacked on to an existing protocol. If the browser supports keep-alive, it adds an additional header to the request: Following this, the connection ...

MOTHER’S DAY: Facebook Examines Connections Between Moms, Kids
With Mother’s Day on the calendar this coming Sunday, Facebook examined the relationships between mothers and their children on the social network, ...

Police tear open roof to arrest man in connection with stabbing murder
Police have torn open the roof of a Gold Coast home to arrest a man in connection with the stabbing death of 16-year-old Michael Brack.

Paris attacks: Belgium connection probed as terrorist past of Brussels district of Molenbeek under spotlight ...
Prosecutors reveal a growing Belgian connection to the deadly Paris attacks, focusing on a poor Brussels district.

Half of data connections by top 500 Android apps are 'covert' with no effect on user experience
Researchers at the Massachusetts Institute of Technology have discovered that half of the communications connections established by the top free ...

Don’t Let Great Content Fall on Deaf Ears: Know your Connection Strategy
... via employee newsletter when it should have come through small-group manager meetings All of these and more are the result of a faulty connection ...

Brussels Connection Under Spotlight After Paris Killings
(EurActiv) — Prosecutors on Sunday disclosed a growing Belgian connection to the Paris attacks as Premier Charles Michel conceded that a Brussels ...

Be Goofy, Smile At Your Baby: Protection Begins with Connection, Pediatrician Says
VideoPart 3 of a series Andrew Garner wears silly ties and finds it easy to make a goofy face. These are valuable tools for charming the babies ...

Resources last updated: 11/22/2015 1:49:38 PM