Question

ASP.NET 1.1 / VB.NET / SQL 2000

I am generation report using crystal reports 10... the report is working fine but the problem that it is taking too long to load and display the data.

What I am doing is: I have two tables (one to many). I am getting all records from the first table and storing it in a table in my dataset... then I am getting all records from the second table depending on the ID from the first table. then storing it in another table in the dataset.

After that, I merge both tables in dataset by doing for each loop to merge each record to its related id.

Finally, bind it to the report

The merging process takes 2 minutes!!

.

  • What can I do?
  • Is there a better way to do the same thing?
  • Can I control the range of records in my SQL statement?

Important

I can't put my code, because lot of code's there , It's really confusing to all .

Was it helpful?

Solution

Unfortunately, you have not supplied much information but let me give you an exmaple of some code that you should be able to modify to your purpose.

Dim SQL1 As String = "SELECT Field1, Field2 FROM Table1 where Field2 = 7" 'Standard SQL
Dim SQL2 As String = "SELECT Field3, Field4, Field1 FROM Table2 Where Field1 in (SELECT Field1 FROM Table1 where Field2 = 7)" 'This SQL contains a nested select to get the child data for only the records that match the parent
'A neat feature, combine them into 1 SQL statement that will produce 2 tables in your dataset in one call
Dim SQL3 As String = SQL1 & ";" & SQL2
Dim CN As New SqlClient.SqlConnection("Your connection string here")
Dim DS As New DataSet
Dim DA As New SqlClient.SqlDataAdapter(SQL3, CN)
CN.Open()
DA.Fill(DS)
CN.Close()

See notes in the code for explainations of what is happening. Based on your TAGs of VB.net, Sql Server and Net1.1, this should all work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top