• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

Use mySQL 5.0 with Visual Studio 2005

Hey,

I know there is many ways to use mySQL with Visual Studio 2005. The problem is that I need to switch back to MS SQL 2005 easily. Right now I have a global constant containing this connection string to sql 2005:

public const string DBConn = "Data Source=localhost;Initial Catalog=NAITBook Integrated Security=SSPI";

I was hoping that there was a way to just change this string to allow me to connect to mySQL.

0
tqrecords
Asked:
tqrecords
  • 5
  • 5
1 Solution
 
Ryan ChongCommented:
>>I was hoping that there was a way to just change this string to allow me to connect to mySQL

The connection objects are different from MS SQL and MySQL, I very doubt you can do it by just changing the ConnectionString setting.

However, you may try look for the ado.net odbc objects.
0
 
CraigLazarCommented:
Hi,
Depends on your process that u are using to connect, what i do is store the connection string in a config file, so depending on the application, and how the user is working, you can switch automatically between settings. So when my application start up, i have a function which opens a simple config file in the applications folder and then it reads an Entry called "CurrentDBConnection", and this then holds hte value of my db connection string. Like ryancys comment, the data connection inside ur code will be different from SQL to MySql, so in your code u can code around this depending on your value in the confg file. So if its the MySQL conneciton then set the MySQL db connection objects, and the same thn for the SQL connections objects  in run time - How is ur application designed? - do you have a GUI front end?
Hope this Helps
0
 
tqrecordsAuthor Commented:
Hey,

Well all I need right now really is to be able to test my application with mySQL. It is because I do not have SQL Server 2005 installed on my computer.

My application has a front end and a back end. The front end is an AJAX enabled website. This is how I connect to the SQL 2005 Server right now

using (SqlConnection DBConn = new SqlConnection(GlobalConstants.DBConn))

The back end contains the GlobalConstants class which establishes the connection.

All I want to know it the quickest and easiest way to connect to mySQL and be able to change it back to the current set up without too much difficulty. Mainly because I have a project thats due tomorrow and I won't have much time to change the settings!
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Ryan ChongCommented:
>>It is because I do not have SQL Server 2005 installed on my computer.

You can try download the SQL Server Express Edition from M$ website...

http://msdn.microsoft.com/en-au/sqlserver/bb671254.aspx
0
 
tqrecordsAuthor Commented:
You know what???

I had a problem installing SQL Server 2005 Dev Addition because of this stupid corrupt sql.cab error AND I SERIOUSLY RESEARCHED AND TRIED EVERYTHING to try to install it and it would not F&#*%^G WORK!

Does the express addition come with the GUI where you can add tables and such? I am downloading it right now.

If it does then I don't need any of this mySQL bullsh*&t.
0
 
Ryan ChongCommented:
0
 
tqrecordsAuthor Commented:
Hey,

Every thing is installed but I cannot connect to SQL. I receive this error:

An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server

I have made sure that:

1. windows firewall is off
2. SQL Server Browser service is turned on
3. remote connections is enabled

??
0
 
Ryan ChongCommented:
0
 
tqrecordsAuthor Commented:
yes, i did already, followed all the steps and it still doesn't connect..
0
 
tqrecordsAuthor Commented:
yeah one of those out of 100 solutions worked..

I had to change the connection string to:

public const string DBConn = "Server=.\\SQLEXPRESS;Initial Catalog="database";Integrated Security=SSPI";

thanks for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now