Datasources dissappear after load report

I hope there is a simple answer.....

I have a report designer I'm adding datasources via code.....that works great.....until I load a report.....then the datasources I add by code (even if I run it after the report is loaded) defaults to the sources that were used when the report was first created and saved.

Below is an example of how I'm adding the datasources. Can someone tell me how to make these stick or renew after I load an existing report?

Thanks,
Craig


Dim conn As New FastReport.Data.MsSqlDataConnection
conn.Name = "Current Sales Ticket"
conn.ConnectionString = varConnect

Report1.Dictionary.Connections.Add(conn)


Dim invoiceIDParam As New Parameter
invoiceIDParam.Name = "invoiceID"
Report1.Dictionary.Parameters.Add(invoiceIDParam)


Dim tblTicketDetails As New TableDataSource()
Dim tblTicketDetailsParam As New FastReport.Data.CommandParameter
tblTicketDetailsParam.DataType = SqlDbType.VarChar
tblTicketDetailsParam.Name = "@invoiceID";
tblTicketDetailsParam.Expression = "[invoiceID]"
tblTicketDetailsParam.DefaultValue = System.Guid.Empty.ToString
tblTicketDetails.Parameters.Add(tblTicketDetailsParam)
tblTicketDetails.TableName = "Ticket Details"
tblTicketDetails.Name = "Detail Fields"
tblTicketDetails.SelectCommand = "SELECT tbl_invoiceItems.itemPrice, tbl_invoiceItems.itemQTY, itemFreeText, tbl_inventory.itemTitle FROM [dbo].[tbl_invoiceItems] LEFT JOIN tbl_invoiceItemFT ON tbl_invoiceItems.invoiceItemID= tbl_invoiceItemFT.invoiceItemID LEFT JOIN tbl_inventory ON tbl_inventory.itemID=tbl_invoiceitems.itemID WHERE invoiceID=CAST(@invoiceID as uniqueidentifier) ORDER BY sortnum ASC"
conn.Tables.Add(tblTicketDetails)
tblTicketDetails.RefreshTable()


Dim tblTicketPayDetails As New TableDataSource()
Dim tblTicketPayDetailsParam As New FastReport.Data.CommandParameter
tblTicketPayDetailsParam.DataType = SqlDbType.VarChar
tblTicketPayDetailsParam.Name = "@invoiceID";
tblTicketPayDetailsParam.Expression = "[invoiceID]"
tblTicketPayDetailsParam.DefaultValue = System.Guid.Empty.ToString
tblTicketPayDetails.Parameters.Add(tblTicketPayDetailsParam)
tblTicketPayDetails.TableName = "Payment Details"
tblTicketPayDetails.Name = "Payment Fields"
tblTicketPayDetails.SelectCommand = "SELECT paymentAmount,paymentData1,paymentData2,paymentTitle,paymentPrintCCSign,paymentPrintAcctSign FROM [dbo].[tbl_invoicePayments] INNER JOIN tbl_invoicePaymentTypes ON paymentType= tbl_invoicePaymentTypes.paymentID WHERE paymentInvoiceID=CAST(@invoiceID as uniqueidentifier)"
conn.Tables.Add(tblTicketPayDetails)
tblTicketPayDetails.RefreshTable()

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.