Get "levels" Of A Self Referencing Table In LINQ?
Jul 19, 2011
There's a table Category with a pk idCategory and a self-referencing foreign-key fiCategory.That means categories are "main-categories" when fiCategory is null. If fiCategory links to another category, it is a sub-category of it. But it's also valid that this sub-category also has 1-n sub-categories(with fiCategory linking to it's idCategory).Q: How can i get a list of main-categories,sub-categories,"sub-sub-categories", ...etc. with LINQ?I'm using typed DataSets to compare data from Server1/MySQL with data from Server2/MS SQL-Server.After normalizing and cleaning(there are several inconsistencies) i want to import the new data into SQL-Server. First of all i have to import the main-categories, then the sub-categories and so on. Otherwise SQL-Server would throw a constraint exception when i would try to insert a row with a foreign-key to a category that is yet not inserted.
View 1 Replies
ADVERTISEMENT
Sep 2, 2011
I want to make different levels of access for a vb.net program i'm writing.I have a database called "stratocast". I want to show a specific form for entries in this table with "IsManager" checked and another specific form for those with "IsAdmin" checked.Im using MySql server and visual basic 2010 express
EDIT:To clear up any misconceptions about my post, ill explain further: In my vb.net application i have a login form with two textboxes; One for the username and one for password. I also have three other forms, one is called "frmAdmin", another called "frmManager" and another one called "frmEmployee".
On my database i have a table called "employee" with columns called "name", "title", "IsManager", "IsAdmin", "Username" and "Password".
IsManager and IsAdmin are both Boolean columns
This means that their values can only be 0 or 1 and the result is displayed as a checkbox.When the employee logs into this applcation i want it to check whether or not the employee is a manager, an administrator, or just a regular employee with no additional rights. If the employee is a manager, i want to show "frmManager". If the employee is an Administrator i want to show "frmAdmin". And if the employee has no additional rights then i want to show "frmEmployee".
I'd like to keep the configuration for access level checking confined to the one table but if it's better to have separate tables for each level of access (ie: tables called Admin,Manager, and Employee) then ill consider that too.
View 2 Replies
Jun 22, 2011
've got a function that takes two parameters (a delegate and an integer) and then creates a LINQ MethodCallExpression, which it uses to gets the results:
Public Delegate Function CompareTwoIntegerFunction(ByVal i1 As Integer, ByVal i2 As Integer) As Boolean
Public Function Test(ByVal pFunc As CompareTwoIntegerFunction, ByVal i1 As Integer, ByVal
[code].....
View 1 Replies
Feb 15, 2012
I have a question about assigning variables values based on values stored inside an sql database. I have the connection part down, but here is my basic set-up. I have a table with the values {username, password, isAdmin}, where username and password are strings and "isAdmin" is a bit variable. I am able to read in the username and password entered by the user and match it to the database fine, however I would like to also read in the "isAdmin" and set it to a local Boolean variable that will then direct the user to the proper form.
[Code]...
View 6 Replies
Nov 23, 2010
Basically the code below is supposed to load data from a reader into a datatable, then compare a date to the start date and end date in each row of the table.However, I am getting errors on the if statement indicating Overload resolution failed because no accessible '>=' can be called with these arguments.I can probably do this with just the reader but I am playing around with a data table because I know I will have to learn how to cycle through the records and look at them at some point and this is a simple example I can use to do this.[code]
View 2 Replies
Jul 28, 2009
Using VS-2008, VB and SQL 2005 Developer:
I'm using Queries within the TableAdapter to grab certain data record field validations, most of them are using the Scalar Query to see if a certain condition returns a record or not.
I have one check I need to do that SUMs three fields and have tried it with both a Scalar and Regular Select, both return the results fine, my problem is creating the right syntax in the VB code to check the returned values.
Here's the Query Code in the Adapter (called GetInvoiceSum) and I pass it the cJobNum
SELECT sum(taxable) as taxable, sum(material+labor) AS subtotal, sum(tax) AS tax from ticket where jobnum = @cJobnum Here is the Code in the VB app - it gives me errors on the declaration and I've tried various types DataRow, DataSet, etc....not sure what I'm missing here and am very new at this....
Dim nSumTicket As DataSet = Me.TicketTableAdapter.GetInvoiceSum(cJobnum)
View 5 Replies
Dec 28, 2010
I cant grasp it right now, lol. So here's what Im trying to do: I have two tables, a main table, and an employee table, with a foreign key in the main table pointing to the employee number in the employee table. Im trying to use a databound datagrid to show everything from the main table, and the corresponding name of the employee number referenced in the main table. Is there a way I can do that using DataSet.Table.Column.Expression, or what would be a simple way of doing this? I cant use TableAdapter b/c sometimes the database is offline, so preferably with datasets.
View 1 Replies
Feb 19, 2009
I have th is little programm:
Dim dbOud As ADODB.Connection
Dim rsOud As ADODB.Recordset
Dim strCnnOud As String
[code]....
View 1 Replies
Aug 23, 2010
I have two tables Employees and CafeLogs. Some employees can be cashiers and also customers at the Cafe shop.
Table structures:
Employees: EmployeeId(PK) , FirstName, LastName
CafeLogs: LogId (PK), CashierId, EmployeeId, Value, => CashierId and EmployeeId are the data from column EmployeeId of Empoyee table
Table relationship:
Employees 1:N CafeLogs (CashierId (FK))
[code]....
Right now I know how to select only LogId, Employee's name, and , Value, not with Cashier name yet.
Dim query = From log In db.CafeLogs _
Join emp In db.Employees On emp.EmployeeId Equals log.EmployeeId _
Select log.LogId, emp.FirsName, emp.LastName, log.Value
View 1 Replies
Apr 10, 2012
I have 2 Tables Table "A" and Table "B". Here is little details.
Table "A"
---------
ItemID (Primery Key)
ItemSKU
[Code]....
View 5 Replies
Jul 9, 2010
I have a table (Projects) which is linked to projectVersions on projectID..projectVersions contains several columns on which I'd like to filter a returned project (and associated projectVersions) list. For example there is a "capacity" column and a "country" column. I am doing a filtered list of projects on one page and I'd like to include all projects where any one of the associated projectVersions has a capacity of 750ml and a country of "France" for example.It may be that a particular parameter is not set and so I pass a zero to indicate not to filter on that.I guess this needs some kind of subquery as when I try and do something like this: [code] it doesn't work as the "xxx" bit, being one-to-many, expects me to specify an item to get at the entities within and yet I want to query where ANY of the associated versions match one of the criteria.
View 1 Replies
May 18, 2012
I am starting with Linq to SQL in VB.NET, and trying to figure out how to make a simple query to a database.I want to do it all programaticly.I have made a connection to the database with a connectionstring, and this works fine - I can get a message if the database exists or not.But when I want to query a table, I am missing the part where I connest to the table. I have googled a lot to find an answer for thi, but [code]
View 2 Replies
Dec 14, 2009
I am trying to update a table using LinQ. Though records are getting inserted, for some reason they are not getting updated.what can be possible problem
Dim db as new empDataContext
Dim emptable as new employee
if update then[code].....
View 3 Replies
Sep 2, 2009
I was able to use it for querying out info from an XML file but now i have to use the DBF file from a folder. where i can find out how to query out DBF table using LINQ. I basically need to get data from a column of a DBF table.
View 2 Replies
Jun 17, 2011
C# or VB.NET is fine. I'd like to count number of people for each country from the following tables with LINQ to SQL I have two tables, one is Countries and other is People. It's one to many relatoionship from Countries to People. ountries table column:CountryId,CountryName People:PeopleId,FullName,CountryId (a primary key from Country table and allowed null) I want to count how many people each country has and get something like the following result that shows only the country that has people. Because there are some countries that have no people in the People table.
[Code]...
View 2 Replies
Mar 31, 2012
Dim mydata = (From c In dc.Table Select New With {c.ID}).Count
any faster than this:
Dim mydata = (From c In dc.Table Select c).Count
[code].....
View 1 Replies
Mar 2, 2011
I want to populate a LINQ table from code, not DataBase.Is it possible ?System.Data.Linq.Table<Question> myquestions = new System.Data.Linq.Table<Question>();
View 2 Replies
Jun 20, 2012
I need to return the same results from linq as I get using SQL
SELECT DISTINCT Area, Region
FROM dbo.Regions
Union
SELECT null,'All'
Order by 1,2
I use this for showing an "All" selecting in a combo box
My current linq points to a view that does the union for me but I want to know how to do it right in linq. I can't figure out how to union a row for the null,'All' values.
Public Shared Function GetRegions(ByVal Area As String) As IEnumerable
Dim DB As New SiteDBDataContext
Return From values In DB.uv_Areas _
[Code].....
View 1 Replies
Jun 15, 2010
I'm trying to make a game in Visual Basic, but I can't figure out how to add in different levels.
Essentially, what I'm looking for is the Tab Control, minus the tabs. On a different note, is there a way to make a group of controls? Like instead of
TextBox1.Text = "Hello"
TextBox2.Text = "Hello"
I could have something along the lines of TextBoxGroup.Text = "Hello"
View 5 Replies
Dec 15, 2009
whats the difference with high and low level of programming
View 1 Replies
Jan 10, 2010
i have a login form and it has 3 user levels - admin, manager & accountant - which have limited privileges using the system. For ex., if admin logged in, this user can access the whole system; if manager logged in, this user can only access the employee records; & accountant user can only access the payroll.
i actually have the idea but because i lack knowledge about vb.net, i don't know how to code it.
[code..]
At the main menu, buttons are enabled & disabled depending on the user level that was entered.
View 2 Replies
Apr 26, 2010
I have 2 tables Table1 with columns [BId,Name,Amount] Table2 with columns [CId,BId, ExpenseType,Expense]. BId Is the foreign key in Table2. The Amount field in Table1 is always higher than Expense in Table2. I need to update the values of Amount (increase or decrease) based on value of Expense and I want to do it in single query in LINQ. Eg If the Expense has to be updated with 200, I would decrease(negate) Amount value with 200. If Expense is reduce to 100 then the Amount is increased by a value of 100.
View 1 Replies
Aug 22, 2011
I´m trying to update my Students table record using LINQ to SQL. The problem is when one of the Properties of the object changed and 'PropertyChanging' Event is fired using 'SendPropertyChanging()' method.
student_id is a PK
data types are matched
Here is the full ArgumentException:
GenericArguments[2], 'System.String', on
'System.Data.Linq.Mapping.PropertyAccessor+Accessor`3[T,V,V2]'
violates the constraint of type 'V2'.
[code]....
View 1 Replies
Aug 26, 2009
I have a table that contains procedure codes among other data (let's call it "MyData"). I have another table that contains valid procedure codes, their descriptions, and the dates on which those codes are valid. Every time I want to report on MyData and include the procedure description, I have to do a lookup similar to this:
From m in dc.MyDatas _
Join p in dc.Procedures On m.proc_code Equals p.proc_code _
Where p.start_date <= m.event_date _
[Code]....
Is there a way to turn a complex lookup (i.e. a non-trivial join) like this into something SQL can recognize so that I can define it in one place and just reference the description as if it were a field in MyData? So far the only thing I can think of is to create a SQL view on MyData that does the linking and bring that into my data context, but I'd like to try to avoid that.
View 2 Replies
Jan 23, 2012
I have:
string s = "A=1,B=2,C=3";
I need the output in hashtable using LINQ. Hashtable should be filled as
["A"] | 1
["B"] | 2
["C"] | 3
View 2 Replies
Jun 24, 2011
I'm working on a form that has a few data grid views that are populated from LINQ queries, no problem there it works as it should however that sorting does not work. After doing some reading its because LINQ results do not support sorting.As I have the LINQ results already is there a way of copying the results into a dataset or datatable then binding the data grid view to that so sorting will work?
View 4 Replies
Aug 17, 2010
I've got a problem with Linq in VB.NET.I've created a .dbml file from my db, and everything looks good - relation "arrows" between tables are visible, etc.But when I want to use simple query (taken from 101 Linq Samples by MS):
Dim q = From h In dc.Hours, w In h.WorkType
I receive an error:
[code].....
View 1 Replies
Jun 25, 2012
My SQL Server database contains several views which are essentially filtered (WHERE) / ordered (ORDER BY) versions of some of the tables i.e. no joins.
An example would be my Downloads table, which has a view such as DownloadsOnlineOnly e.g.
SELECT * FROM Downloads WHERE Live = 1 ORDER BY FolderName ASC;
I can drag and drop these views onto my LINQ to SQL DataContext, and use LINQ to query these views and retrieve data fine...
But the foreign key relationships are not being picked up in my DataContext, so I've lost the ability to:
Dim dl as DownloadOnlineOnly = (From r in db.DownloadOnlineOnlies Select r).First
Dim fol as Folder = dl.Folder ' Syntax error as there is no association between
' DownloadOnlineOnly and Folder in my DataContext.
I understand why this is happening, but how can I get around this:
Without manually adding associations in my DataContext? Can I change the type of the Entity like changing the return type of an SP on the DataContext? Can I cast or convert between a DownloadOnlineOnly object and Download object? Or some other method?
View 1 Replies
Jun 12, 2009
hello everyone, i m using treeview control in vb .net . How do we usee a recursive function to add data at different levels from different tables in a database.
View 2 Replies
Jan 12, 2010
I'm looking for a recursive subroutine.I have the dataset from sql-server with in the datasource-table a parent- and a child-column.
I made a routine to put the parent-nodes in the tree.The problem starts with the childs over so many levels.I can write it out but it is to much code, I'm sure it can be done more efficient with a recursive subroutine.
.tv_Ana.Nodes(A).Nodes(B).Nodes(C).Nodes(D).Nodes(E).Nodes(F).Nodes(G).Nodes(H).Nodes.Add(Trim(sLev_nI + "-" + row_nI("MidCod").ToString()))
The tree will be about 25 levels deep.A few days ago I saw a recursive subroutine to fill the childnodes without the above difficulty to write alle the levels in code.That example I cannot find it any more, but it had a line of code more or less like this here below:
Dim
Nodes As TreeNodeCollection = tv.Nodes(A).Nodes
but it doesn't work yet!
View 5 Replies