VS 2008 Use Queries And Dealing With Databases Using LINQ Or SQl / Which Is Better To Start

Jul 6, 2010

I will start a new project, use the queries and dealing with databases using LINQ or SQl ,Which is better to start ???

View 4 Replies


ADVERTISEMENT

LINQ Queries - Combine The First 3 Queries Into A Single Query And Place In A List?

Jan 6, 2010

I am writing a message system on my server, the xml is something like this

<xml>
<entry>
<sender>[code]....

my problem now i guess is 2 fold, i wish to combine the first 3 queries into a single query and place in a list or a collection or is there a way to do this with a single query that will give me my desired result?

View 1 Replies

.net - Nested Queries From Multiple Oracle Databases

Jul 21, 2011

In .NET, Is it possible to run a nested query from two separate Oracle databases?

[Code]...

Ultimately, this is an effort to overcome an "ORA-01795" error from using an "in" statement with over 1000 items in the conditional list, without having to break the query out into multiple "OR value IN" lists.

View 3 Replies

[2008] Dynamic LINQ Queries And Select Statements?

Jun 5, 2008

I've recently ported my website from 2005 to 2008, and I'm using LINQ Queries to implement a search. The issue is that none of the fields are mandatory, so I've had to implement a dynamic LINQ Query (sic?). Here's the relevant code -

Public Function searchQuery(ByVal titleType As String, ByVal titleName As String, _
ByVal configMgr As String, ByVal lifecycle As String, _
ByVal CIType As String, ByVal recordsPerPage As String) As IEnumerable(Of

[code].....

View 2 Replies

Dealing With Linq Formatting In Visual Studio?

Jul 28, 2010

Does anyone else wrestle with getting VB.NET Linq code formatted the way they want it in Visual Studio? What are some tricks you have for how do you deal with it? I know that Visual Studio lets you uncheck the option for "Pretty listing (reformatting) of code", but most of the time it's a really handy setting to keep on. And with a team of developers who could have other settings, that's not really a viable solution. So my questions are:How have you dealt with formatting multiline Linq statements in VB without fighting with Visual Studio's code formatting?Is there a particular style guide for Linq in VB.NET that is recommended? Something that is readable, and that Visual Studio likes without the reformatting nightmares? My original question may not have had the clarity I desired. Here's a more concrete example. [code]

Everything is all nicely formatted and lined up, but any changes to the query result in Visual Studio borking the formatting and only an immediate CTRL-Z will stop it. Which is fine if there's a standard way that VS would like to see multiline Linq formatted, but if not, then the constant reformatting VS tries makes no sense. I'm trying to see if I missed some standard or how others in the community deal with this effectively. (BTW - using tabs instead of spaces for indents.

View 2 Replies

Sql - "INNER JOIN" The Results Of Two Different Queries From Two Different Databases?

Jun 13, 2012

I connect to SQL Server database and grab a DataSet of the result with the following function:

[Code]....

View 3 Replies

.net - Know To Refresh Linq Queries?

Aug 24, 2011

I have a basic grid of Linq2Sql entities (frmList). I have a separate form for editing (frmEdit). frmEdit has its own DataContext (as that appears to be the recommended way). How can I tell when my detail form has saved changes?

I don't see a built-in method. I am considering raising an event on the detail form when I save the datacontex, but not sure how I consume this event on frmList, and I have a feeling these events are already created for me somewhere?

View 1 Replies

Linq Combining 2 Queries?

Oct 11, 2010

Let's say I have 3 tables: carts, baskets and eggs where a basket can contain many eggs and where carts contain many baskets. Each basket has a foreign key that maps to a cart and each egg has a foreign key that maps to a basket.I need to return a table that contains these 3 columns:Cart Name | Count of Baskets in Cart | Count of Eggs in Cart.Each table is an EF and I'm using linq with VB.So far, I have 2 queries: one that returns the columns Cart Name and Count of Basket and another one that returns Cart Name and Count of Eggs. How can I combine these two result tables so that I get the results in one table?

Dim query1 = (From cart In myEntities.Carts
Where cart.UserID = TheUserID
Join baskets In myEntities.Baskets On baskets.CartID Equals cart.CartID

[code]...

View 2 Replies

.net - How To Merge LINQ-to-SQL Queries Optimally

Mar 13, 2012

I have a function used to filter a list of options to return only those that are lot traced, and, when applicable, also only show items matching a specified pattern:

Private Shared Function FilterResultsLot(ByVal source As IQueryable(Of Item), _
ByVal itemCode As String) As IQueryable(Of Item)
If HasFilter(itemCode, True) Then

[Code].....

View 1 Replies

Do Queries Against Hierarchical Data Using LINQ To SQL?

Mar 17, 2009

I have 2 tables that are related. Each app can relate to many apps. ie, office can be related to word, excel.[code]I would like to do the following query. I use vb.net but c# is ok.Query is to return all the apps that are not related to (1), so the result should be (4, quake) .

View 3 Replies

Application Accessing Databases And LINQ

Mar 31, 2012

This application uses a Microsoft Access database named Books to keep track of the books in a store. The database has one table named tblBooks. The table has five fields. The BookNumber, Price, and QuantityInStock fields are numeric. The Title and Author fields contain text. This application should allow a user to enter an author's name ( or part of a name ) and then display only the titles of books written by the author. Displaying the information in a DataGridView control; however, don't allow the user to add, delete, modify, or save records. I need to allow the user to specify the records he or she wants to select while the application is running. Also, i need to Add a text box and a button to the BindingNavigator control. The user will use the text box to specify the records he wants to select. The user will use the button to tell the computer to display the selected records. I also want to display the total value of the books in the store. I am not getting the BindingNavigator control in the component tray in my program I've included. Also I am working on the code for the display button but I need some tips. I am trying to complete this program and only expect guidance.[code]

View 12 Replies

Asp.net - The Specified LINQ Expression Contains References To Queries That Are Associated With Different Contexts?

Apr 5, 2011

I know there are similar questions on stackoverflow - and I looked through them and think my issue is somewhat similar, but haven't been able to find a solution by looking at any of these other questions/answers.I'm getting the error when attempting to execute the following code:

Private Sub btnReserve_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReserve.Click
' Check that the room is still available.
Dim dbCheckOccupants As New pbu_housingEntities
Dim hall As String = CStr(Session("hall"))

[code]....

It is catching an error on this line:

Dim myID As String = GetID.First.id.ToString

As far as I can tell I'm not using multiple contexts?

View 2 Replies

ComboBox DataBinding DisplayMember And LINQ Queries

Apr 7, 2009

I decided to iterate through the Data.DataTable and trimmed the values there.Utilizing SirDemon's post, I have updated the code a little bit:

[code]...

I know that on the DisplayMember line the .First.Item() part is wrong, I just wanted to show what row I am trying to designate as the DisplayMember.

View 3 Replies

LINQ. Reducing The Code By Using Dynamic Queries?

Feb 17, 2011

I use the following code to fill the Table1 dictionary with the information found within the LINQ query.

Dim DB As New DatabaseDataContext
Dim Table1 As New Dictionary(Of String, Integer)
Dim Table2 As New Dictionary(Of String, Integer)

[code].....

View 3 Replies

Working With System.collection.generic.Ienumerable/XML Linq Queries?

Oct 22, 2009

This is really a continuation from my earlier post. I've never worked with this datatype/collection (system.collection.generic.Ienumerable) before so I'm struggling to declare the query globally so I can reference the results within other sub routines/functions. I also am struggling to convert it to other types.how I can convert the collection of xml elements/system.collection.generic.Ienumerable into an xmltextreader (I know I will have to change the query below as it select the value of the node and not the node itself) I imagine by converting the query result to system.IO.stream My first port of call was MSDN but I find the material very difficult to understand for this particular subject.

[Code]...

View 3 Replies

VS 2008 : Dealing With Large Numbers?

Mar 12, 2012

I want a method of dealing with very, very, very big numbers (potentially a million digits). It is very cumbersome to deal with very big numbers in VB, would another language perhaps be better for that?

View 10 Replies

VS 2008 Dealing With Appearance Of MDI Form

Jan 14, 2010

I have a main form which contains a few buttons...some of those buttons open up smaller forms...there is also a button for each of those smaller forms, which should let me bring the chosen form to the front and give it focus...basically like the tabs in your task bar let you switch between which program you are using...but I'm having trouble with this...I need to click the button 2 times before the form I want comes to the front...the first click removes focus from the currently activated form the second click then moves the form I want to the front.I need this to happen in one click..I[code] figured out the exact cause of the problem.it's due to the fact that the first click doesn't actually take effect since the child form has focus...so the first click actually just transfers focus to the main form...the second click does what it should.I knew it was going to be extremely obvious.so the question now becomes...how can I overcome this if that is possible at all...I know I've seen applications where I can still activate functions of the parent form in one click even if I have a child form open and focused.And it's basically what I need...it does what I want and lets me switch between child forms in one click...but it stuffs up the entire look of my parent form...the layout and colors get wacky...the transparency of certain things don't seem to work and my background image is gone..

View 7 Replies

VS 2008 Making A Program Dealing With Change?

Oct 11, 2011

Write a program that makes change for amounts less than one dollar. Input to the program should be an integer less than 100. Output should be the original amount together with the proper set of coins that add up to that number. The program should produce change consisting of the minimum amount of coins possible. The output should be printed in such a way as to avoid unnecessary amounts.For example:

32 cents should be printed as:32 requires 1 quarter, 1 nickel, and 2 cents Rather than� 32 requires 1 quarter(s), 0 dime(s), 1 nickel(s), and 2 cent(s)

View 7 Replies

VS 2008 - Class With Attribute / Dealing With DBNull Values

Dec 22, 2010

I wonder, what is the most elegant way of dealing with the dbnull situation. I have a class, with attribute, let's say: "End_Date", which is being read from database. Type of this variant should be date, but as it's the "End_Date", there might be the situation that something haven't ended yet, and in the database in this field I have a null value.

Right now a deal with the problem this way:
Dim mEnd_Date
...
Public Property End_Date ()
Get
End_Date = mEnd_Date
End Get
Set(ByVal value)
mEnd_Date = value
End Set
End Property
But I am not sure if that's a good way as I don't declare variants as any datatype?

View 5 Replies

2008 - Draw Random Numbers From Comboboxes For Dealing Cards

Jan 23, 2009

I'm trying to make a program that'll play the card game "War". I've started to code the dealing process, but it doesn't seem to be working. I currently have 3 comboboxes on the form each with numbers representing different cards, 1 that contains all the cards to be dealt, 1 that contains the user's cards, and 1 that contains the computer's cards. I plan to just draw random numbers from these comboboxes for the dealing. However, nothing happens when I click the tool-strip button that's supposed to deal the cards. [Code]

View 5 Replies

XML To LINQ Start The Search From Root?

Oct 29, 2009

So far I don't got problems searching elements for example , the next block of code will load the xml file and then will search descendants ("recordinfomation") which is a parent element in the XML file and returns child elements ("title", "aut_FirstName, "aut_LastName, and "xmllink") . My question is I would like to start my search at the root of the xml file and search all parent elements and not a specific one and return what I am returning in the following code. In another words search the whole document for specific child elements.

Dim XDoc As XElement = XElement.Load(MapPath("App_DataBookstore.xml"))
Dim elements = From row In XDoc.Descendants("recordinformtion") _
Where Regex.IsMatch(row.Element("title").Value, strfirstterm,

[Code].....

View 1 Replies

VB2005 Parameter Queries With SQL 2008?

Dec 7, 2009

We have recently updated our SQL Server to 2008 (from 2000). I moved all the data over to the SQL 2008 server by exporting from the 2000 server. All the tables open just fine, and all the data appears to be present. Within the VB.NET app, however, any table reference that uses a parameter generates an error: The data types text and text are incompatible in the equal to operators. The table adapter works just fine with full table previews, but not with either parameters or filter values (i.e., Field1 <> '0'). I should confess that I am new to SQL 2008. What do I need to do to get these parameter queries operational?BTW, I have downloaded and installed the VB2005 plugin that enables working with SQL 2008 (VS80sp1-KB954961-X86-INTL.exe).LDC

View 3 Replies

VS 2008 : Perform Sql Queries On Xml Files?

Dec 18, 2009

can i perform sql queries on xml files?

View 9 Replies

VS 2008 Searching Queries In A Database?

Sep 5, 2009

I'm using oledbdataadapter for query lets say i have a fields Firstname, Surname, Location, Gender

Firstname| Surname| Location| Gender
Angel David Alaska Female
David Leonard Alabama Male
Michael Reeves Indiana Male

i want to filter data so that if I put a keyword %david% and select combobox as "MALE" it will search david on the first three fields and return

David Leonard Alabama Male

View 19 Replies

VS 2008 Using Variables / Parameters In Sql Queries?

Sep 20, 2011

I am using Visual Basic 2008 / MYSQL

Basically i have 2 tables in mysql called Data and products

The first sql query i want to do is something like this to scroll through the recordset of products and bring back information;

dbquery.commandtext = "select quantity, sku, condition from products"

But then what i want to do is bring back information from the Data table based on the sku and condition of the first sql?

so it would be something like this

subquery.commandtext = "select lowestprice from data where sku = *SKU FROM FIRST TABLE* and condition = *CONDITIONFROM FIRST TABLE*"

View 6 Replies

VS 2008 Write Database Queries On The Fly?

Jan 29, 2010

Is it possible to create database queries on the fly with VB?

For i = 0 To (UBound(WeekNo) - 1)
For NLoop = 1 To 50
WeekRow(NLoop) = WeekSinceLast(i, NLoop)
Next
Next

I want to write each WeekRow to the database for each week (= i). WeekRow contains 50 elements, each of which needs to be placed in a separate field.

So, can I generate a SQL query that is constructed on the fly? If so, how do I go about it?

View 13 Replies

DB/Reporting :: Databases Using VB 2008?

Apr 8, 2009

I am making a program that will take your initial balance of your checking account and then you can enter your checks, deposits and withdrawls into a database. Then The option will be given to return a report of deposits, withdrawls, etc. Well, I am having the problem with creating a database I can open when the program runs, first time to get the initial balance, and after to tell current balance. Then, I need to just keep on adding the new checks, deposits, withdrawls to the database everytime the person uses it. So, say I used it and put in 5 checks and then a week later I use it and put another 5 in. I want to be able to give a report of all the checks that have been inputed (this example is 10) back out to the user. So, essentially my question is, I guess, how would I create a database in VB 2008 that I can keep adding to it everytime it gets used?

View 1 Replies

VS 2008 Cannot Edit Databases?

Aug 15, 2009

I'm relativity new to VB programing and was working on implementing a database into my current project. However last night I was trying to add one and the program had encountered some error while I was trying to add a database which I accidentally closed without reading, at which point i promptly restarted the program to find this error whenever I try to open/edit the database.This leads me to believe that the error had stated that it was disabling something on me, and perhaps some way to re-enable it. I cant seem to recreate the error on my other system so i have no idea what to do.

View 2 Replies

VS 2008 Using Parametrized Queries With Multiple SQL Statements

Jun 25, 2009

There is not a VB.net database forum, and there is a HUGE difference (unfortunately) between ADO and ADO.net. I have a connection to a MS SQL database, which I understand is capable of handling multiple SQL statements in one Execution, ie

Using cmdExe As New System.Data.SqlClient.SqlCommand
sSQL = "Delete * from mytable where UniqueID=123;Insert into mytable (UniqueID, Field) values (123, 'something')"
.CommandText = strSingleSQLLine

[Code]....

There are two questions here actually...can I add the parameters before setting the command text, and do I have to add the same parameter over and over again?

View 3 Replies

VS 2008 General Approach To Databases?

Jan 20, 2010

I am often asked to create a very simple database front-end for friends or family, and the structure of the database (and application) is usually very similar.Right now I am always creating a class that handles all database interactions with some shared functions. For example, there's a function to run a general query and return a table, a function to save/load various items (depending on the application of course). The point is: the code is nearly always the same except for some slight variations.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved