.net - Populating A List Box With Variable Names From LINQ Generated Class?
Nov 17, 2009
I'm quite new to Visual Basic - using Visual Studio 2008 and can't seem to find a way to do the following:
I have a few tables in a SQL Server database and have used LINQ to SQL to create classes of those tables.
Here's a cut down example of what I'd like:listbox1 filled with table names - APS, SMPS, WCPC, CFLAPS
Then from the SelectedIndexChanged event, listbox2 should populate column headers of the selected table.
I have no issues getting data from the database, and can access all of these headers through the anonymous type objects created from a LINQ query (eg APS.ID, APS.count etc), but populating a listbox with these variable names rather than the data inside them seems rather elusive.
This is probably a cross platform coding question rather than VB specific, so if you have a solution in C# or whatever I'd be happy if you could let me know.
View 2 Replies
ADVERTISEMENT
Jan 28, 2009
I am populating a combobox with a list of names that are coming from a database. I would like to get the names to show up in the combo box in alphabetical order. [code] There is also another combobox I'm populating with text from a database. (as below). However, in the database, in the column I'm reading data from, there are a few duplicate rows and then when the combobox is populated, the same text can be seen 2/3 times. What can I do or add to my existing code, that will ensure that there is no duplication shown in the combo box? [code]
View 3 Replies
Jun 21, 2011
I'm returning a list of database records;
Dim rsPublicChilds As System.Data.Linq.ISingleResult(Of spGetPublicObjectsResult) = Nothing
rsPublicChilds = dc.spGetPublicObject(slintLoginID, lintLanguageID, lintObjectID, lintObjectTypeID, lstrSEOURL, lstrValid)
I get an enumerable list of rsPublicChildObjects that I then convert to an array;
Dim larr_PublicChild As IEnumerable(Of spGetPublicObjectsResult) = rsPublicChilds.toArray()
That then gives me easy access to an array of the objects, so I can then do;
larr_publicchild(0).colMyValue
etc.etc
I'd like to get the minimum value of colMyValue (or any other property of the object that's been created for me) but I can't quite see how to get there.
View 1 Replies
Apr 15, 2012
im pretty much a beginner to using ASP.net and linq to sql but what im trying to do is update a column of a table based on a variable. at the momment i have
Dim db As New sqldcDataContext Dim update As tableName = (From i in db.tableNames _ Select i)
i think this selects everything, how could i have two variables, one to store what table to update and the other what column. is this possible?edit: sorry for being unclear im trying to make this as dynamic as possible so i dont have to type in the exact table/col names. something like this but in the linq to sql syntax.
mysql_query("SELECT * FROM ". $table ." WHERE `" . $column . "` = "" . $data ."");
View 2 Replies
Dec 18, 2009
What i'm trying to do:
I've got a library which includes a class:
Class Human
End Class
and another class which refers to the human class
Class ASD
Private somevar as new Human
End Class
Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.
Well its something like a PHP on Javascript.
the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:
note: in php $ sign declares a variable, echo writes the variable out
CODE:
Is there anyway to do that with VB?
View 6 Replies
Oct 26, 2011
I have these objects:[code]Using LINQ I need to take a List(Of MakeInfo) and a List(Of ModelInfo) and aggregate the StockInfo from ModelInfo into the List(Of MakeInfo).So for each MakeInfo I will have a total count of all stock where MakeInfo.Name = ModelInfo.Make, and also a minimum price.I think it's going to be something like this, but I'm having trouble accessing the nested object and not sure if it's going to be possible with a single query.[code]
View 2 Replies
Jan 9, 2009
Trying to understand the best way to do this and I'm can't get it figured. Here's basically what I have:
Public Class CardParsingClass
Private iAcctIDStart as integer
Private iAcctIDLength as integer
[code]....
I've only included 2 of the class level fields here but there are actually 30, so that's why I was hoping to be able to send the name of the field to set and the value to set it at in the SetValue function. So in some other routine in the program I'd like to be able to issue the following call:
SetValue("iAcctIDStart", "3")
But then when I get into the SetValue routine, I'm not sure how to proceed. I thought about a case statement that would basically be this:
select Case strFieldToSet
case "iAcctIDStart"
iAcctIDStart = cint(strValue)
[code]....
View 5 Replies
Aug 12, 2011
this website seems great and this is my first post. Sorry if this has already been answered but I have been searching for a long time. I have a program with a list view in details mode. I have it load column settings (visibility, display index, width, etc.) when the form is opened and save them when closed. There are many columns...about ten so far...like folder, file, size, etc. Is there a way to access variable names from the values of other variables?
[Code]...
View 3 Replies
Feb 1, 2011
I am working on a project where my class has to execute VB code provided by the user, to make it simple I am trying to recreate my own eval function, I am using the following code I found on the web to do this task.
Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection
[Code] .....
The problem with code is that it can't access any variables or there values, so I have decided to get the variable names, there values types and there types dynamically and recreate them in the class that is being created dynamically. Any way to get the variable names there types and values in the current class or method, so that I can recreate them, and execute the user passed code, the user knows what variables are in the current class or method and there datatypes but he don't know there values as they may have changed, so he can't initialize them. Is there a way to do this, this code will be called in an asp.net page on page_load event, the code passed by the user is stored in the variable vbCode that is passed as a parameter.
View 2 Replies
May 26, 2012
y have this class
Private Class MyClass
Public Property propertyOne() as String
Public Property propertyTwo() as String
[code].....
View 2 Replies
Apr 30, 2010
I'm using the following code to sort a List(of Class) using LINQ. It works fine, but I'm wondering if there is a better way to do it. I'm basically taking one list, applying LINQ to it, then using the result to create a second list in the sorted order. Can I do this without creating a second list? Here is my sample
' KeyMatch is my Class Variable
' mMatchList is the Unsorted List
'
[code].....
View 3 Replies
Feb 4, 2010
In my project I am using a LINQ to SQL class that contains a stored procedure which includes a string value as an output parameter.So to capture that, I created a string variable as follows in the procedure:Dim spOutput As String? However, when I do this I get the following message "Type 'String' must be a value type or a type argument constrained to 'Structure' in order to be used with 'Nullable' or nullable modifier '?'"
View 2 Replies
Sep 5, 2011
I am doing work for a client who has lost the source code for one of their VB.Net WinForms applications. The assembly they have is not obfuscated at all. I am trying to recover as much of the source as I can as C# source and have tried several tools for decompiling assemblies, including Reflector, ILSpy and JustDecompile (all the latest versions), but they all produce code with a huge number of errors in them. Because of the large number of errors in the generated code, I am going to ask about the specific errors (in different questions), get more directed answers and in this way try shed some light on why all the tools are having difficulty decompiling this assembly. This question pertains to the fact that the code generated by all these tools always have a large number of invalid member variables (fields) such as the following:
private short $STATIC$Report_Print$20211C1280B1$nHeight;
private ArrayList $STATIC$Report_Print$20211C1280B1$oColumnLefts;
private StaticLocalInitFlag $STATIC$Report_Print$20211C1280B1$oColumnLefts$Init;
why the generated code has these invalid member variables?
View 3 Replies
Nov 4, 2011
According to the General Naming Conventions the usage of CLR type names (e.g. String, Int16) should be preferred over the usage of language specific type names (string, short). I usually follow this advice. Resharper however seems to use the language specific type names when generating code (eg. when extracting methods or generating foreach loops) which is very annoying.
View 2 Replies
Feb 25, 2012
I'm trying to produce a repeater showing amounts of money taken by various payment types into a table.Payment types available come from a global settings file as an array, I am creating a dataTable by looping this list and extracting sales reports (there might be a more efficient way than this loop, but this is not my concern at the minute).My question: How do I bind this to a repeater and display it when I dont necessarily know the table column namesI've tried various methods to give the table a header row and give the columns numerical names from a for > next loop, but am either getting no results, orystem.Data.DataRowView' does not contain a property with the name '7'. < or whatever numberThis is where I currently am:
EDIT: JUST REALISED MY CODE WAS AWFUL, SO UPDATED:
Dim paymentTable As New DataTable("paymentTable")
For j = 0 To UBound(paymentTypes)
[code]....
View 1 Replies
Apr 8, 2010
I am not too sure about the syntax , since I am still very new to VB..
So this is what I have in a class
Code:Public Class DocumentDelivery Implements IDisposable Public Shared RenderList As New List(Of Byte()())
Public Function Initialize(ByRef env As et.User.SystemCommon.Environment, ByRef errs As et.Exec.Utilities.ErrorCollection) As Boolean
[Code]...
I didn't write the existing class, I am just making changes to it. I am not sure why there is no constructor. However, Intialize() is called every time a the class is created.Right now, I set the default capacity of the RenderList, (the class variable) to 1 in Initialize method.
Is there a way to set the capacity outside of the initialize method? what is the syntax?
View 1 Replies
Jan 13, 2011
I am used to C like languages such as C#. I added a list box with a list of names. In the code behind I added the below code. When I run the code I am getting the MessageBox but it will state "UserName favorite color is " but does not show the color. I thought it might be misspelled or non-matching names but this is not the issue due to the names being correct.
Public Class Form1
Private Sub lstData_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstData.SelectedIndexChanged
'Declare Variables
[CODE]...
View 4 Replies
Aug 24, 2010
Is there any way to know that a variable inside a method is Compiler generated.when decompiling a .net dll or exe the generated code looks like this. [code]
View 8 Replies
Jun 22, 2011
i am trying to automatically generate multiple text boxes on a form with the following code
Private Sub CreateTB(ByVal x As Integer)
Dim y As Integer = 1
Do Until y = x
[Code]...
i need it to generate as many text boxes as the variable x states, so i used the do until loop thing. But i am stuck when it comes to naming the text boxes because obviously all the text boxes cannot share the same name. so i would like to know how to programmatically name each textbox uniquely.
View 5 Replies
Mar 10, 2009
My program handles XML files that have certain elements within a root-child node that are identical expect for their inner text value. So while populating my combo box with all of a root-child's child element's names I get like five identical items listed. Which brought about the problem of selecting say the third item and getting the value of the first displayed. So I came up with a loop function that determines if the selected combo box item is preceded by one of the same name, if it is, then it adds +1 to a counter variable and keeps checking farther and farther up the list. Once it loops to an item that doesn't have the same name it exits and it reads the Xth (X = counter mentioned earlier) element's inner text from the file. This works great for elements 1, 3, 4, and 5. But not for 2. A while back when I was focused on this problem I discovered the root of the problem but I was unable to circumvent it. I'll put the loop below so you can see the problem in action instead of trying to follow my verbose explanation:
[code]...
View 3 Replies
May 10, 2011
I have an existing vb.net application which uses a home grown database. The database has over 60,000 unique multi-field records in it.The user can search in each field using drill-down to find a record, and then can add that record to a separate database.(60,000 collectibles described in a master database. User can drill down by category, manufacturer, year produced, etc. to find a record and then add it to their own 'collection', 'wanted', 'have for sale', or 'spares' database for record keeping.)
Instead of having them drill down, I would like for them to be able to perform a search and have all of the results (any amount of matches from 1 to 60,000+) appear on a scrolling form with a checkbox next to each so that they can simply check any that they want and do a mass add to their list databases.
The part I cannot figure out is how to have vb.net (2008) create a variable length scrolling form with the results, and how to identify the checkboxes (generated by the system for search matches) to see which, if any, have been checked by the user.
View 1 Replies
Jan 26, 2010
I have a textbox control with a button then underneath of it a have a checkboxlist control and another button. Basically what I want to do is when a User enters something on the textbox and then press the Add button the text they enter gets added to the checkbox list. This I was able to do with no problems, The problems comes when I try to remove the selected Items on the checkbox list. I have the following code.
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim myPhoneNumber As String = txtPhoneNumber.Text
Dim myListOfPhoneNumbers As CheckBoxList = CType(chkPhoneNumbers, CheckBoxList)
[code]....
View 4 Replies
Mar 16, 2011
Below is a form which produces a graph, the idea is to produce 6 random numbers from a range (0,6) place the numbers in an array then use these numbers to produce columns on the graph, however at the moment it is using the numbers more than once, how can I get it to just use the values once only in the array.
Private Sub btnGraph_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGraph.Click
txtAns.Text = ""
g.Clear(Me.BackColor)
g.DrawLine(Pens.Black, 50, 70, 50, 420)
[Code] .....
View 7 Replies
Dec 9, 2009
I am working on making a Windows based application within Visual Basic 2008 Express that could potentially be used for a music school as a project. This application is connected and bound to a Microsoft Access database. Within this application I have a form for adding a new appointment reservation. This form has a combo box that the user can select the lesson type (eg. "I want a piano lesson"). Upon being changed, a list box would be populated with the names of all instructors that have that selection as either their primary or secondary talent.So, my database is bound, the query is written (correctly...i hope), and I don't know how to 1) select the table column that I want displayed in the list box and 2) actually display the query results within the list box. Is this making sense? Probably not, bu
Private Sub cmbLessonType_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbLessonType.TextChanged
'populate the lboInstructor box
[code]....
View 5 Replies
Feb 22, 2009
I have multiple drop down lists on a page. They all contain list of countries. So in the background I am getting countries from database and caching them. I would like to populate those drop down lists from another thread. I am also using AJAX controls so I wanted that it all happens at the same time. And also after a user selects a country I want that towns from that country show to the user, and I want that getting towns happens also in another thread so that user can fill other controls while the list is not yet loaded.
I have read somewhere that I should give Page as a parameter to that thread and then find that drop down lists and populate them. But that is not working.
Here is a function that is called when another thread starts:
protected void GetCountries(object o)
{
if (Session["Countries"] == null)
{
[Code]....
View 1 Replies
Sep 22, 2009
Imports MySql.Data.MySqlClient
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As MySqlConnection
[code]....
I can't quite figure out how to populate the dang list with that code, am I doing something wrong?
View 3 Replies
Mar 8, 2012
I want to poplate a checked list box based on a column from a datasource or standard listbox based on a selection from a combobox adding each item as I select it in the combo box.
Obviously populating direct from the data source would be best
View 2 Replies
Feb 2, 2011
I am using LINQ to SQL queries to return data in my application. However I find it is now needful for me to return the column Names. Try as I might I have been completely unable to find out how to do this on the internet.
So if my LINQ entity table has the properties (Last_Name, First_name, Middle_Name) I need to return[code]...
View 2 Replies
Feb 17, 2010
i'm worried about doing this since my changes will be overwritten when the dbml file is auto generated again (as they often are).i'm thinking of doing a partial class and writing out the same properties to annotate them, but worried that it will complain about duplicates, and the reason i can't even experiment brings me to the second part of my questions...
that, the expandable arrow on my dbml file listing is missing, right clicking and selecting "View Code" just displays an empty partial class as below.
[Code]...
View 2 Replies
Jul 10, 2010
1. I want to know how the checked list box can get generated by a folder full of mp3's
2. I want the search funktion to refresh the list so it is only the typed in textbox1 that are showed but in the same way it is now
i use 1 textbox and 1 checkedlistbox
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
'Retrieve the item's Checkedlistbox
[code].....
View 5 Replies