Re: MySQL and strongl typed datasets
Posted by: Steve Duff
Date: March 08, 2006 04:11AM

I've got a reasonable workaround going for this using VS2005 and a small additional tool. The tool writes an xml schema file the tables you've selected from your schema. Here is the relevant fragment:

MySqlConnection connection = new MySqlConnection(sConnectString);
connection.Open();

DataSet dataset = new DataSet(dataSetName);

foreach (object table in checkedListTables.CheckedItems)
{
MySqlDataAdapter adapter = new MySqlDataAdapter("select * from " + table.ToString(), connection);

adapter.FillSchema(dataset, SchemaType.Source, table.ToString());
}

dataset.WriteXmlSchema(textFilename.Text);

connection.Close();

Although the code uses a checked list, the best thing to do is to create an XML schema per table - you'll see why in a moment. I create a separate folder in my project for the table schemas. Note that these schemas are NOT added to your project. To create a strongly typed data set you add a new DataSet to your project. This opens a blank DataSet Designer for your new empty dataset. You then open the XML schema file for each table of interest - each opens in it's own designer. You then just drag each table onto the designer for your new dataset. When you drag the tables over, the designer creates the DataSet code for you. If you add more than one table you can add relationships in the normal way.

Curiously this drag and drop exercise is not required for Windows Forms projects. If you add an XML schema to a Winforms project the DataSet generator kicks in automatically.

I should say I'm still using MySQL 4.1.11 on Debian.


Hope this helps.

Options: ReplyQuote


Subject
Written By
Posted
Re: MySQL and strongl typed datasets
March 08, 2006 04:11AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.