Monday, March 12, 2012
How to suppress the group header session when no record return?
RegardsCreate tow formulae
Formula1 @.Reset having the code
Numbervar c;
whileprintingrecords;
c:=0;
Formula2 @.Count having the code
Numbervar c;
whileprintingrecords;
c:=c+1;
Place Formul1 at PageHeader and Formula2 at Details.
In the section expert of Group header write this code at suppress option
numbervar c;
if c:=0 then true|||Hi
The above solution didn't work for me. However, I think the following should work:
1) Create an additional section above the already existing section(s) in the details.
2) Move the contents of the group header to the newly created section in the details.
3) Suppress the group header.
4) Create a global variable, say @.isFirstRecordInGroup, which you set to true in the group header.
5) Suppress the newly added section in details (which now contains the previous contents of the group header) if @.isFirstRecordInGroup is false. Otherwise, if @.isFirstRecordInGroup is true, don't suppress and set @.isFirstRecordInGroup to false.
In this way, the contents that were previously placed in the group header will now be shown as part of the first detail in each group. Hence, if there are no details, nothing will be displayed.
Admittedly, this hack does not render the report more understandable for other programmers, but it should fix the problem.
Wednesday, March 7, 2012
How to store/display more than one tables/recordset
can return more than one recordset/table
the datagrid can show more than one table at a time.
1.the problem is how to store more than one table in a dataset at a time.
2.see sql(2),sql(3), the new table 't1' is empty, after exec sql(3) will meet a "System.Data.OleDb.OleDbException",the sql(2) can pass without return recordset, but sql(3) return a null recordset(maybe). What should I do.
thanks.
Public Function m_execsql()
Dim connStr As String
connStr = "User ID=sa;Password=sa;Initial Catalog=Northwind;Provider=""SQLOLEDB.1"";Data Source=MINGLEI"
conn = New System.Data.OleDb.OleDbConnection(connStr)
conn.Open()
Dim sql(3) As String
sql(0) = "select * from products;"
sql(1) = "select * from orders;"
sql(2) = "create table t1;"
sql(3) = "seletc * from t1;"
Dim i As Integer
For i = 0 To sql.GetUpperBound(0) - 1
Try
da = New OleDb.OleDbDataAdapter(sql(i), conn)
Catch e As Exception
MessageBox.Show(e.Message)
End Try
'Try
ds = New DataSet("dsTable")
dt = New DataTable
da.Fill(ds)
'grd.SetDataBinding(ds, i.ToString)
grd.DataSource = dt
'Catch eds As Exception
' MessageBox.Show(eds.Message)
'End T
Next
conn.Close()
conn = Nothing
End Functioniqueen, you can use multiple data adapters to fill one dataset or if your sql statement returned more than one result set.
Here's more from MS KB:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpopulatingdatasetfromdataadapter.asp
You may want post in .Net section too...
Sunday, February 19, 2012
How to stop running DTS package if my view return zero record?
Hi everyone,
I've created a DTS package runs on every day and night, but now my boss was asking if I can insert an exception code to check the view file.
So.. I need help from you guys, cause I don't know How.
This is my DTS description.
My DB will generate a view called "Calls to Add", then it will run the Transform Data Task and insert into a txt file. once it finished, it will run the Batch file. that is it.
Now My boss wants me to add a checking code between "View to Txt" procedure. If the view has no record inside, than the DTS package should stop and not run.
BUT How? Can someone please help? Thanks
Kelvin,
This is an SSIS forum (not DTS).
Sorry.
|||Not sure, and I second Rafael's comment, but can you put in a row counter against the view and test it's result?|||I did, but I don't know how to put it into a package.?
Please Help......
|||Kelvin Y wrote:
I did, but I don't know how to put it into a package.?
Please Help......
If you are using SSIS, and not DTS, you can use an Execute SQL task in the control flow to query the view and capture the row count. (select count(*) from view) Then in the control flow you can test the variable that was previously populated with the Execute SQL task for a condition of != 0, and if so, continue processing.|||
OK. here's another idea....slightly different from Phil's. Give it a shot. (using SSIS again)
The SQL task has a property "ForceExecutionResult" that you can configure using exprssions. Get the count from the view exactly like Phil explained above but instead of using a conditional split, use the value to set the exprssion to Success or Failure.
You wont be able to log an approiate error message though.
P.S: For some reason the use of the word "e x p r e s s i o n" is causing my post to be truncated. So, had to use "exprssion"
|||Thanks everyone, but I can't find the "ForceExecutionResult" property.
Can you tell me where is it?
Thanks
|||
If you dont have experience with exprssions, I'd suggest using Phil's approach.
But to answer your question, you can find the property under the "misc" category about 6th in the list.
|||Thanks everyone, it works now. Thanks for helping me out.|||Kelvin Y wrote:
Thanks everyone, it works now. Thanks for helping me out.
Please mark this thread as answered.