Friday, July 31, 2009

How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?

In JAVA I used to use a class which told me where the class was located. I'm trying to tell the application that the database is in the solution but how do i do it?





I've got an OLEDB database, but i dont know how to formulate the connection string. The database is inside the Visual Studio solution but I dont know how to tell it that.





Please help...

How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?
Right click on your solution explorer and select properties. Go to the settings tab, type a name for a new setting (like DatabaseConnectionString) and select [Connection String] as the type. A wizard will popup allowing you to select a database; select your database. From now on, you can access this connection string using the Settings namespace, it would be:





Settings.Default.DatabaseConnectionStr...





I find this method much easier for doing this than remembering how to formulate the connection string. Adding the DB to your application solution really doesn't do anything for connecting to it.
Reply:OLEDB won't give you anything about the connectionstring. You dont really need to know where it is located.


I am using MYSQL database and when installed that MYSQL connector I just added it to each page i needed to work with MYSQL like this:





using MYSQL.data;





this way I get all the classes I need to connect and work with my database.


I hope this helps you


No comments:

Post a Comment