473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

MySQL and the GetSchema method

Thanks for your time.

I've been trying to get a list of databases available on a mySQL server
(local) using the OdbcConnection.GetSchema() function. Thus far I have
only been able to get "views". Can anyone help me out?

code:
OdbcConnection c = new OdbcConnection();
c.ConncetionString = conString; // the connection works fine, so I have
not bothered to add it
c.open();

DataTable t = c.GetSchema(); // At this point I have seen people use
the "Databases"
// arg but it tells me
that there is no such collection.

How can I get the list of available databases? I know that it can't be
all that difficult, but I just can't seem to figure it out.

Using .NET 2.0 and SharpDevelop (I also have VS 2005 and I could use a
SQL server if need be, but I wanted to give mySQL and SharpDevelop a
try)

Aug 22 '06 #1
1 6161
I have solved the issue. For those interested parties:
public string retreiveDatabases() // The OdbcConnection has already
been made
{
string databases = "";
try
{
tempQuery = "show databases;";
data = new DataSet(); //
This is declared elsewhere.
da = new OdbcDataAdapter(tempQuery, conn); // This is also
declared elsewhere
da.Fill(data);
DataRow row;
for(int i = 0; i < data.Tables[0].Rows.Count; i ++)
{
row = data.Tables[0].Rows[i];
databases += (string)row[0] + "|"; // i'm using a .Split
on the calling method
}
return databases;
}
catch(Exception exc)
{
MessageBox.Show(exc.Message, "Error");
return "Could not load the database information!";
}
}

This works. It was just way too simple. I have been wresting with
this in my spare time for two days now, and I don't knwo how I
overlooked this. It's not like I didn't know the command! Oh well,
hopefully, someone can learn from my foolishness.

Aug 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Leepe | last post by:
example: I have a skill object that implements the XmlSerializable interface Implementing the getschema gives me some unwanted generations towards the wsdl.exe Reference.cs generation. skill is...
0
by: Brian Keating | last post by:
Hi there I want to get a list of databases on my server so I do this SqlConnection.GetSchema("Databases"); However is it possible to restrict the Databases to just user databases? i.e. exclude...
0
by: cwho.work | last post by:
Hi! We are using apache ibatis with our MySQL 5.0 database (using innodb tables), in our web application running on Tomcat 5. Recently we started getting a number of errors relating to...
0
by: Hexman | last post by:
Hello All, I am wanting to make a small utility that allows the user (me) to select a local database (currently Access 2000), build a list of non-system tables, then select a table which will...
3
by: h4xPace | last post by:
I am building a MySQL query application, and I have run into a small snag. MySQL has released a set of classes that extend the .NET framework base data classes (command, connection, etc), and I am...
5
by: Ken | last post by:
I'm trying to run a loop to capture column property information from a table in my datasource. Can anybody see where this is going wrong? Dim tbl As New DataTable Dim col As DataColumn Dim x...
6
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
0
by: Sebastijan | last post by:
Hi I am interested in DbConnection.GetSchema method of ODP.NET oracle library. When I call (to get primary keys metadata) DataTable pkeys = DbConnection.GetSchema("PrimaryKeys"... foreach...
3
by: Jaydeep Ramavat | last post by:
Dear Friends, how can we get the default value of the columns using getschema functionality. is there any alternative is available? Regards Jay.
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.