VS 2010 LINQ2SQL - How To Add Conditions Runtime
Jun 20, 2012[Code]...
How to create a LINQ query that allows the end user to choose a few months?
[Code]...
How to create a LINQ query that allows the end user to choose a few months?
I want to change the font on a button to bold after certain conditions exist during runtime.
I tried
Col1Button.Font.Bold =
True
The autocomplete allows me to type it, but it doesn't work. There is an underline under the IDE code. Font is apparently a "Read-Only"property. Is there a way to make it a changable property?
I'm programming a utility for a game, and at the moment I am adding chat commands for it. They use the Select Case type, but I want to be able to use multiple conditions for 1 case.
Current
Case "/lame"
If sParameter = "announce" Then
AnnounceMsg("^1No Laming
^7Laming consists of
^5* ^7Attacking someone with
^5- ^7Weapon Down
^5- ^7Chatbubble Up")
[Code] .....
I get an error:
Conversion from string "/lame" to type 'Long' is not valid.
how to make linq2sql behave like my custom code used to, I want to check to make sure that it isn't already "built" in behavior that I can just use by setting up the relationships right in the designer...
Very simple example: I have two tables: Person and Notes, with a 1 to many relationship (1 Person, many notes), linked by Person.ID->Note.PersonID.
I have a stored procedure (all data access is done via SP's and I plan on continuing that) which makes the Link2SQL a bit more work for me.
sp_PersonGet(@ID int) which returns the person record and sp_PersonNotesGet(@PersonID) which returns a set of related notes for this person.So far so good, I have an object:
Dim myPerson As Person = db.PersonGet(pnID).Single
and I can access my fields: myPerson.Name, myPerson.Phone etc.and I can also do a
Dim myNotes As Notes = db.PersonNotesGet(pnID)
to get a set of notes and I can iterate thru this list like:
For Each N As Note In myNotes
( do something)
Next[code].....
Basically, Linq2SQl would need to call 2 stored procedures each time a Person record is created...Is this doable "out of the box", or is this something I need to code around for myself?
I have this one line property
Public ReadOnly Property DateToUniversal(ByVal dt As Nullable(Of Date)) As String
Get
Return If(dt.HasValue, dt.Value.ToString("u").Substring(0, 10), "")
[code].....
I want to use Linq2Sql as the data source for my Crystal reports. I have all my data in my domain objects in the form of Lists. The problem is all my domain model resides in a different namespace in the form of a .dll. And when i try to assign a data source for my report in Database Expert window, under .NET Objects, i can only see classes that are available in the current project and not from other projects in my solution, nor from other namespaces.
View 1 RepliesI've got a very simple data structure. I'm using SQLExpress with Linq2SQL and vb.net
**ParentClass**
parentId
name
[code].....
I set up a test harness by checking for and then deleting records added to the db in the previous testing session, and then I test my recording adding code by adding back the same records.Interestingly this code works fine when there is a break in the debugger, but fails with a "duplicate key" exception when I let it run with no breaks, which leads me to believe there is some kind of concurrency issue.The basic metacode is as follows:
DoTest()
dim j as datacontext
dim recs = from myrecs in j.mythings select myrecs where myrecs.key="key1" or
myrecs.key = "key2"
[code]....
I've confirmed that I'm properly deleted the previous added records, and this works fine as does adding the new records when I have a break in the code before I hit the add records step. but without the break, it throws duplicate key exceptions in the "addrecordestomytable" method suggesting that it hasn't grabbed the current version of the table when it creates the new data context in addrecordstomytable, even though the records should have already been deleted.I've tried refreshing the table, but this doesn't seem to work either.Note backing database is ms sql server 10?
I set up a test harness by checking for and then deleting records added to the db in the previous testing session, and then I test my recording adding code by adding back the same records.Interestingly this code works fine when there is a break in the debugger, but fails with a "duplicate key" exception when I let it run with no breaks, which leads me to believe there is some kind of concurrency issue
View 1 Replieswhat is the most robust method for adding a empty row (to select "nothing") to a ListBox?
Dim List = Enumerable.Repeat(New TABLE With {.Text = "", .ID = -1}, 1).AsQueryable().Union(From t In mainctx.TABLEs)
ddlMangelKategorie.DisplayMember = "Text"
ddlMangelKategorie.ValueMember = "ID"
ddlMangelKategorie.DataSource = List.ToList
But this has some drawbacks:wordy must explicit write the Type (TABLE in this case), so i cant wrap this in a function have not found an solution, which works with anonymous types I.e. if I add a From t In mainctx.TABLEs Select Text=col1, id=col2 to the query, this method does not work anymore.
I am new in programming an application with GDI+. I found that the graphics are fade at runtime. Probably it is associated with some settings.
View 4 RepliesPublic Class Inventory_Edit
Private Sub Inventory_Edit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'CategoryDataSet.Category' table. You can move, or remove it, as needed.
Me.CategoryTableAdapter.Fill(Me.CategoryDataSet.Category)
[URL]
I added an "edit" icon on my bindingNavigator. When users click on it, a new form will come out and pull out all the data records from the datagridview. Now the strange thing is that when I wanted to edit the data records, when I left the product name blank, I would get an error message saying "Product cannot be blank" - please see above code. But when I left the "Cost Price" blank(same applies to "Sell Price" and "Quantity"), the error message box wouldn't come out, instead, it did not allow me to move on to another textbox, close the form etc until I filled out that textbox with INTEGER. May I know why the error mesagebox would not come out when I entered the wrong datatype?
the testBoolean is set to the value True, but for some reason when debugging, it step through both conditions, so in the end the button1.visble becomes False, but I want it to be set to True.[code]....
View 14 RepliesI am very new to vb, I know there is an error somewhere, I had an assignment which stated that if a number was < 101 or > 500 and the answer is correct the output should be, for example-123, if the answer was wrong then the message output should be wrong number <101>500. Everytime I type in a number(no matter what the number) and click on my check button I get the output message. If at all possible, can you please assist. My professor gave the following example, but I am still not getting it:
Dim strInteger As String = "52.801"
Dim dblNumber As Double
dblNumber = CDbl(strInteger)
[code].....
I am trying to create an application that can block Windows keys at runtime in VB .net. Basically, if 'Disable Left Win Key' check box is checked, then the application will disable the left windows key and the same for the right one. I also want to be able to show a message box depending on whether 'Show Message Box' is checked when either win key is blocked.
View 2 RepliesI am working on a project that I want to allow the user to move and resize controls in a panel container at runtime, much like the developer can do in the IDE.Is there a mode (not sure its the right term) I can implement on a selected control that will show the grab handles and allow moving and such?
View 6 RepliesHow do you move objects in run-time?
View 1 RepliesIs ist possible to Add or Edit Resources of .Net Applications at Runtime because I want that the User is able to pick a file and that is automatticly added to the Resources so the Application can use that file later on.
View 3 RepliesI need a little help with variable scope ( I think that is the right term) As I understand it, the follow could be used to add a button to my form at runtime ...
[Code]...
I want a method that creates a new button with the object name that I pass to the method.
Is there a way to change reference at runtime ? I am automating Word from VB.Net. I think what I have coded will be same for both Word2003 and Word2007. I used Word 12 Object Library reference(which is of Word2007). So, I want to know how to make it compatible with a machine installed with Office2003. That is, it will check the whether the machine has 2003 installed. If so, use that reference. Otherwise use 2007.
[Code]...
I am working on getting ready to make a chat client. I want to be able to click a button and a new form come up as a tutorial to myself. Here is the code I am currently using.
CODE:
I'm creating an application that allows the user to create their own queries based on criteria in various list boxes and my idea was to produce the results of the SQL in a "new" DGV, which in turn will be created in a "new" TabPage in a separate form . Each time the user runs a query a new DGV and TabPage is created. I've named each "new" DGV based on a user textbox so each "new" DGV will be named differently. The problem is how do I reference each new DGV? At the moment I get-"the value of type 'Syst.cannot be converted to string"It allows me to name the DGV with a string, but not reference it!
Any ideas how I reference a DGV when its created in runtime.
[Code]...
Is it possible to create and execute code at runtime?Eg, I make a string with this as the data: MessageBox.Show("Test")Then I 'run' the code from this string to produce a MessageBox
View 8 RepliesHow can it be done? What I want is to have the program make a string, and then read the string as code. I'm a noob, and it sounds like this should be so easy, but after seeping through this forum, I have found no quick and easy solutions...
[Code]....
I am using the following code to move a label at runtime when I mousedown on it and drag it, but how can I make it move freely and randomly around the form without any human intervention?
Private Sub label2_Mousedown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label2.MouseDownIf e.Button = Windows.Forms.MouseButtons.Left Then
[Code]...
I created an application that I use when deploying packages which allows users to postpone it from running until they are ready. There are two text boxes that contain restart warning messages.
Is there a way I could use an external file such as an INI where I could place a different message? If the app could read the messages in the text file at runtime and place them in the appropriate text box, it could make this app a little more flexible.
As it is now, if managers want the message changed, I have to change it in the source and recompile. That is not a good way of accomplishing the change.
What's wrong with the following code? I'm trying to remove some radio buttons that were created dynamically but the controls' names are not being picked up by this code (only the name of the type of control).
[Code]...
method to export a resource (an .accdb file) at runtime ?I've had success in exporting image files by using :-
My.Computer.FileSystem.WriteAllBytes("filepath", My.Resources.filename, False)
Unfortunately this method dosen't enable the export of the file type I need. For various reasons the file must be exported at runtime?
I want to use a value that is pulled from the SQL within the if statement. Ideally i want to do the equivalent of <% If DataBinder.Eval(Container, "DataItem.BookID") == 1 Then%> Is there a way to do this with the correct syntax?
View 2 RepliesHow to combine these two conditions in one section
Private Sub DataGridView1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) Handles DataGridView1.CellValidating
'condition 1
' check given value is numeric or charactr type
If e.ColumnIndex = 3 Then
If Not IsNumeric(e.FormattedValue) Then
DataGridView1.Rows(e.RowIndex).ErrorText = " must be a numeric value"
[Code] .....
'condition 2
' check given value is greater than 0 or not
If e.ColumnIndex = 3 Then
If (e.FormattedValue.ToString = "0") Then
[Code] .....