2 Attachment(s)
failed to enable constrains.One or more rows contain value violating non-null,unique,
Hi Everyone:
I am trying to print my voucher data but its giving above mentioned error.I am very new in this field and tried several time to solved but failed.If any one can help me i will be thankful. Here is my code:
Code:
Try
Cursor = Cursors.WaitCursor
Timer1.Enabled = True
Dim rpt As New rptVoucher
Dim myConnection As SqlConnection
Dim MyCommand As New SqlCommand()
Dim myDA As New SqlDataAdapter()
Dim myDS As New DataSet3
myConnection = New SqlConnection(cs)
MyCommand.Connection = myConnection
MyCommand.CommandText = "SELECT Pettycash.ID, Pettycash.Pettycashno,Pettycash.Date, Pettycash.Accountno, Pettycash.Accountname, Pettycash.Amount, Pettycash_Details.VD_ID,Pettycash_Details.Accountname, Pettycash_Details.AccountNo, Pettycash_Details.Billref, Pettycash_Details.Narration, Pettycash_Details.Amount FROM Pettycash INNER JOIN Pettycash_Details ON Pettycash.ID = Pettycash_Details.VoucherID where Pettycashno='" & txtVoucherNo.Text & "'"
MyCommand.CommandType = CommandType.Text
myDA.SelectCommand = MyCommand
myDA.Fill(myDS, "Pettycash")
myDA.Fill(myDS, "Pettycash_Details")
rpt.SetDataSource(myDS)
frmReport.CrystalReportViewer1.ReportSource = rpt
frmReport.ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Attachment 179030
Attachment 179031
Re: failed to enable constrains.One or more rows contain value violating non-null,uni
As I commented on Stack Overflow, why are you executing the same query twice to populate two different DataTables? Either you want all the data in one DataTable, in which case you execute the query once, or you want it in two DataTables, in which case you execute two different queries with no join.
Re: failed to enable constrains.One or more rows contain value violating non-null,uni
Also, what's up with this:
Code:
Dim myDS As New DataSet3
What is a DataSet3 is that a typed DataSet? If so, why are you creating all your own ADO.NET objects instead of using table adapters?
Re: failed to enable constrains.One or more rows contain value violating non-null,uni
Quote:
Originally Posted by
jmcilhinney
Also, what's up with this:
Code:
Dim myDS As New DataSet3
What is a
DataSet3 is that a typed DataSet? If so, why are you creating all your own ADO.NET objects instead of using table adapters?
Hi Sir,
Yes DataSet3 is my DataSet
Re: failed to enable constrains.One or more rows contain value violating non-null,uni
Quote:
Originally Posted by
jmcilhinney
As I commented on Stack Overflow, why are you executing the same query twice to populate two different DataTables? Either you want all the data in one DataTable, in which case you execute the query once, or you want it in two DataTables, in which case you execute two different queries with no join.
Hi Sir,
Actually i want it to in Two DataTables but i don't know how to execute two different queries with no join.Please help me out sir.