473,757 Members | 8,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ConncetionStr ing = 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 6197
I have solved the issue. For those interested parties:
public string retreiveDatabas es() // 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
3836
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 an object with properties name and code public System.Xml.Schema.XmlSchema GetSchema() { string _namespace;
0
3980
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 system databases? I'm finding it impossible to get my answer in msdn. thanks for any help regards
0
11702
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 java.sql.SQLException: Deadlock found when trying to get lock; Try restarting transaction message from server: "Lock wait timeout exceeded; try restarting transaction"; We get such errors generally on inserts or updates while applying a
0
5637
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 then populate a datagridview with the column name, default, null, if primary key, etc...... I've seen the code for obtaining this info before, but can't rememeber where. Can anyone help? Using vb.net 2005. The code below allows the user to...
3
5993
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 using them to interact with the MySQL server (on localhost). Everything works great on that side of the aisle. However, I have never worked with getting schema from a database before, so I am fumbling around for a workable solution to doing...
5
25578
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 As Integer Dim colName(99) As String Dim colType(99) As String cn.Open() tbl = cn.GetSchema("Orders") 'Orders is a table in the
6
38518
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 through this without much trouble. Programming knowledge is not required. Index What is SQL? Why MySQL? Installing MySQL. Using the MySQL command line interface
0
2723
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 (DataRow dr in pkeys.Rows) { string pkTable = dr.ToString();
3
3224
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
9489
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9737
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.