Hi guys,
I've been having one hell of a night with a particular item. The code is as follows.
Error on: dt.Load(reader)Code:Public Function getClientsDeptCodes(ByVal user As String, ByVal password As String) As DataTable Dim dt As New DataTable command.CommandText = "SELECT Clients.ClientID, ClientName, DeptCode FROM Clients " & _ "LEFT JOIN TollDepartmentCodes ON (Clients.ClientID = TollDepartmentCodes.ClientID);" command.CommandType = CommandType.Text command.Connection = connect.getConnection Try connect.connectionOpen(user, password, "DB") reader = command.ExecuteReader dt.Load(reader) connect.connectionClose() Catch ex As MySql.Data.MySqlClient.MySqlException errorsender.messageOut("clients", ex.Number, "getClientsDeptCodes", ex.Message) connect.connectionClose() End Try Return dt End Function
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.
The table is as below
CREATE TABLE IF NOT EXISTS Clients
(
ClientID VARCHAR(4) NOT NULL UNIQUE,
ClientName VARCHAR(40) NOT NULL,
PRIMARY KEY (ClientID)
);
CREATE TABLE IF NOT EXISTS TollDepartmentCodes
(
DeptCode VARCHAR(4) NOT NULL UNIQUE,
ClientID VARCHAR(4) NOT NULL,
PRIMARY KEY (DeptCode)
FOREIGN KEY (ClientID) REFERENCES Clients (ClientID)
);
Item used here.
When I run the query through MySQL command line, the query works fine. But VB.Net does not like it for some reason... Any help would be great. If you need more info I can provide. Thanks.Code:cboClient.DataSource = clients.getClients(frmLogin.txtUserName.Text, frmLogin.txtPassword.Text) cboClient.DisplayMember = "ClientName" cboClient.ValueMember = "ClientID" cboClient.SelectedIndex = -1 cboClient.Text = ""





Reply With Quote