Hi,
Was wondering if anybody could help.
I've just installed the MySQL .NET Connector and try retrieve data from it..
I have been using the following code, but everytime the dataset is empty :(
using System.Data;
string strDatabaseLocation = ConfigurationSettings.AppSettings["DataConnection"];
DataConnection = new MySql.Data.MySqlClient.MySqlConnection();
DataConnection.ConnectionString = strDatabaseLocation;
DataConnection.Open();
string SQLQuery = "SELECT UserID, Forename, Surname, Password FROM users";
MySql.Data.MySqlClient.MySqlDataAdapter DataAdapter = new MySql.Data.MySqlClient.MySqlDataAdapter();
DataAdapter.SelectCommand = new MySql.Data.MySqlClient.MySqlCommand(SQLQuery, DataConnection);
DataAdapter.Fill(UserInfo);
// At this point UserInfo is empty, it has no records!!
// So I tried the following
DataTable data = new DataTable();
DataAdapter.Fill( data );
// data contains the rows of data!!
Wasn't sure if it was anything to do with my Dataset that I have created..
//// Dataset Start
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="dsLogonUserInfo" targetNamespace="
http://www.tempuri.org/dsLogonUserInfo.xsd"
xmlns:mstns="
http://www.tempuri.org/dsLogonUserInfo.xsd" xmlns="
http://www.tempuri.org/dsLogonUserInfo.xsd"
xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="dsLogonUserInfo" msdata:IsDataSet="true" msdata:Locale="en-GB">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="users">
<xs:complexType>
<xs:sequence>
<xs:element name="UserID" msdata:AutoIncrement="true" type="xs:long" minOccurs="0" />
<xs:element name="Forename" type="xs:string" minOccurs="0" />
<xs:element name="Surname" type="xs:string" minOccurs="0" />
<xs:element name="Password" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1">
<xs:selector xpath=".//mstns:users" />
<xs:field xpath="mstns:UserID" />
</xs:unique>
</xs:element>
</xs:schema>
//// DataSet End
Any help would be extremely welcome..
Thanks
Wayne