Is it possible for an Excel user to see the attributes of dimensions in any order he chooses after using DrillThroughAction (or something similar)?
We currently have a cube where DrillThroughAction is defined, but VS won't let you set the same dimension again. All the attributes of the given dimension should be selected at once.
(target server version 13)
Example as is:
Dim Account.Account ID
Dim Account.Account Type
Dim Customer.Customer Email
Dim Customer.Customer Country
An example as the user would like:
Dim Account.Account ID
Dim Customer.Customer Email
Dim Customer.Customer Country
Dim Account.Account Type
Is there any solution or workaround for this other than a dedicated report?
Related
I am creating a library management system. I want to generate different book code for different book genre. For eg:- There is a combo box with book three book genres(novel,literature,poem) and there is another text box with book code. I want if someone chooses novel in comboBox, book code starts form N001 and if someone chooses literature in comboBox, book code starts from L001 and if someone chooses poem, book code starts from P001.
(My vb application is connected with ms access database.)
I see several problems with your fundamental numbering strategy.
Most library numbering systems (Dewey Decimal/Library of Congress) factor sort ordering abilities to their numbering system and allow for future additions to be able to sort higher without needing to shift the number of all other items. With your incremental strategy, how would you accommodate inserting a book later in the process?
If you set up with three digits of numbering, what would you do once you get 1000 books in a category?
While you could use a magic number table that includes the last id allocated per category and increment it as you add a new book. If you have more than one user, there is a potential for a race condition where two users get the same last number and both try to increment it at the same time landing on the same new Id.
I typically recommend keeping a generic ID that has no meaning in the system. This number would be set as an Auto Number in Access and the database would generate new Ids when records are added and ensure that you don't have the collision issue above. If you absolutely need a publically viewable Id, you can use the magic number strategy for a separate BookNumber column that isn't used for record identity. That way if you have a collision in the future, data won't get corrupted.
there are several schools of thought on how one can approach this.
One way? Well, you say have a book type or some such, and then you have that book code. It would be a simple number column without the prefix (P, B etc.).
So, to get the next number, you would then go:
myBookNumber = DMAX("BookNumber","tblBooks","BookType = 'P')
MyBookNumber = MyBookNumber + 1
So, you simply store the book number separate from the prefix. In forms, reports etc., you can then always display the book number like rst!BookType & rst!BookNumber
Another way, which I prefer is to create a table that allows you to get the next book number This also makes it easy to add more types, and better is such a design lets you set the starting number. This approach is also often used for invoice numbers.
So, you create a table called tlbBookIncrements. It will look like this:
ID: (pk - autonumber)
BookType: text (the one char book type)
BookNumber: Number the next book number to assign.
You then build a function like this:
Public Function GetNextBookN(strBookType As String) As Long
Dim strSQL As String
Dim rst As DAO.Recordset
strSQL = "SELECT * FROM tblBookIncrement where BookType = '" & strBookType & "'"
Set rst = CurrentDb.OpenRecordset(strSQL)
If rst.RecordCount = 0 Then
' this book type does not exist - lets add it and start at 1
rst.AddNew
rst!BookType = strBookType
rst!booknumber = 1
End If
GetNextBookN = rst!booknumber
rst!booknumber = rst!booknumber + 1
rst.Update
rst.Close
End Function
Update:
The poster was using vb.net, not VBA, my bad.
Here is the above as vb.net, it really much the same.
Public Function GetNextBookN(strBookType As String) As Integer
Using mycon As New OleDbConnection(My.Settings.ConnectionString1)
Dim strSQL As String
strSQL = "SELECT * FROM tblBookIncrement where BookType = '" & strBookType & "'"
Using da As New OleDbDataAdapter(strSQL, mycon)
Dim cmdBuilder = New OleDbCommandBuilder(da)
Dim rst As New DataTable
da.Fill(rst)
da.AcceptChangesDuringUpdate = True
With rst
If .Rows.Count = 0 Then
With .Rows.Add
.Item("BookType") = strBookType
.Item("booknumber") = 1
End With
GetNextBookN = 1
Else
GetNextBookN = .Rows(0).Item("booknumber")
.Rows(0).Item("booknumber") += 1
End If
End With
da.Update(rst)
End Using
End Using
End Function
So, now anytime you need a book number, you can go like this:
Say, in a form, you need to assign the book number, you could go like this:
You could say use the on-insert event of the form, and go like this:
me!BookNumber = me!bookType & GetNextBookN(me!bookType)
So, the above would say if the bookType is "P", result in P101 if the numbering table has a book type of P and the booknumber set to 101. And of course once you pull that number, then the handy dandy function will increment the number for you.
And I also added the feature that if the type requested does not exist, then we add the type and start at 1. This way, the code works as you over time add new types of books, and then the book number table will always work, and have available a next book number easily available in code.
I'm using Visual basic 2010, I've created 3 text boxes with which i want the user to enter an ID number into the id number and all others will populate the first and last name associated with the ID. I also want the datagridview to hone in on the row with the corresponding first and last name and ID number. I appreciate all your help, thanks!
I populated my database with this:
Last_NameTextBox.Text = strLastName.ToString
First_NameTextBox.Text = strStudent.ToString
IDTextBox.Text = strIdNumber.ToString
DataGridViewStudents.DataSource = MyDataRow.Table()
DataGridViewStudents.Rows.Add(MyDataRow)
'Search id
Dim findId() As Data.DataRow
findId = MyDataRow.GetChildRows(txtId.Text)
I have the following code which selects some rows using LINQ depending on some conditions.
Dim cname
Dim Category
Dim cprice
Try
For i = 0 To mainDatatable.Rows.Count - 1
cname = mainDatatable.Rows(i)("cname")
Category = mainDatatable.Rows(i)("ccategory")
cprice = mainDatatable.Rows(i)("cprice")
Dim nameparts() As String = cname.Split(New String() {" "}, StringSplitOptions.None)
Dim query = From products In mainDatatable.AsEnumerable()
Where products.Field(Of Integer)("ccategory") = Category And products.Field(Of Double)("cprice") = cprice And products.Field(Of String)("cname").Contains(nameparts(0)) And products.Field(Of String)("cname").Contains(nameparts(1))
Select products
If query.Count > 1 Then
'then i want to do some changes to those rows
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
The code is working perfectly but I need to do changes on the selected rows. I'm not sure how to do it, for example i have a column called gprice and I want it to set it to some value for all the selected rows and save changes to mainDatatable ,would aprreciate your help.
To make it clear, suppose the row count in the query is 6 then I want to make all the values for some column in the query = 1 and then update the values of the selected rows in the mainDatatable
------update
If you don't get it forget the above code and here is what I am trying to do
-Ii have a datatable it only have 2 columns product name and product price, now there are products with same name but different colors
-I want to group those products by pharsing the string name and check for other products with identical words in the name, only one word is allowed to differ which is the color,
-Also the price have to be the same between the products in that group and this is what the above LINQ code does and it does it perfectly
-My problem is i have added a third column called groupnumber, I want to add 1 for each product in the 1st group, 2 for each product in group 2nd and so on.
Okay so I have a listview control with 3 columns:
Year | NetTotal | GrossTotal
also i have a table called Orders with several columns, they contain information about the order and store the ID of the Customer they belong to.
Question is: how can i query that table with (preferably) linq (the datacontext is from LinqToSql) to return the following data?
I want to search for any entry with the matching CustomerID which took place, group them by Year, Sum the Totals respectively and add them to the listview?
I now i could use lamda expressions and aggregate, its just not clear how (option infer on,db is a datacontext object,CustomerID is an int32 variable):
Dim Orders = (From order In db.Orders Where order.CustomerID = CustomerID).GroupBy(Function(p) p.Date.Year).GetEnumerator
I reckon i'd have to create an anonymous type like the following:
Dim tmpYears = From prevs In db.Orders Select New With {.CustID = prevs.CustomerID, .Year = prevs.PaymentDate.Year, .NetPurchase, .GrossPurchase}
But how do I aggregate the Purchased column in a group?
Dim CustomerOrders = From ord In db.Orders Where Ord.CustomerID = custID Select ord
Dim tot = From O in CustomerOrders Select Aggregate netTot In O Into Sum(netTot.Price * netTot.Quantity * 1+ (netTot.Discount/100))
I want to merge the two.
Any suggestions? (I've read this but i want it in Linq because its a team project and we agreed on using Linq instead of sending .ExecuteQuerys and etc to the db.Also its a LinqToSQL solution so would be better if i could make some use of it)
I can't guarantee I understand your requirements exactly, but long story short it seems you want to display orders, grouped by year, with the aggregated sums for net/gross value, where the orders match a provided CustomerID?
Sorry if the syntax is slightly out but I'm doing this freehand...
Dim results = db.Orders.Where(Function(n) n.CustomerId = customerId).GroupBy(Function(n) n.Date.Year, Function(key, values) New With {.Year = key, .NetTotal = values.Sum(Function(n) n.NetPurchase * n.Quantity * (1 + (n.Discount/100))), .GrossTotal = values.Sum(Function(n) n.GrossPurchase)})
This should provide you an anonymous type with Year, NetTotal, and GrossTotal populated as per the requirements I listed.
EDIT: Also apologies for the one liner but I'm sure you can reformat it to taste.
I'm not sure how to go about this. Currently, in the first gridview, is a list of groups a member has access to. The second gridview is bound to a table that contains a list of every type of group and has an Add button which adds it to the first gridview and updates a table adding that group to a member.
This is what I am trying to do:
When the Add button (in the second gridview) for a row is clicked, it will be added to the first one (like it currently does), but I would also like it to disappear from the second gridview. So basically, a group should only be visible in either the first gridview or the second, not both. The problem I have is I don't want to modify the table because obviously the table contains all possible groups. Any suggestions?
I would do all the work on the database side. Data source for first one is:
Select g.*
From membership m
inner join groups g on m.groupid=g.groupid
Where m.userid = #userid
Data source for the second one looks like
Select g.*
From groups g
Where not exists
(Select 1 from membership m
Where m.GroupID=g.GroupID and m.userid = #userid
Then your add button inserts the appropriate row in the table and requeries both grids.
You could simply make changes to the Dataset, then .AcceptChanges and re-bind. This would ensure the data would update on the screen without actually pushing it to the database.
Pseudo example:
Dim dt as Datatable = GetData1(strSQL.toString)
Dim dt2 as Datatable = GetData2(strSQL.toString)
Public Sub MoveRecord(ByVal dt1 as DataTable, ByVal dt2 as Datatable, ByVal index as Integer)
'Record being moved '
Dim dr as Datarow = dt.Rows(index)
dt2.Rows.Add(dr)
dt2.AcceptChanges
dt.Rows.RemoveAt(index)
dt.AcceptChanges
'Bind Gridview
Perhaps store new changes in Viewstate,
Cache, or Session for Paging, Sorting'
End Sub
Of course, this assumes the grids have the same fields. If they don't, you'd have to:
Dim drN as DataRow - dt2.Rows.NewRow
'Assign rows from moving datarow to new datarow'
dt2.Rows.Add(drN)
dt2.AcceptChanges