VS 2008 : Class Property That Accepts DataSet Or DataTable As Argument?
Jul 21, 2011
I'm working on a helper class that will make things easier for me when connecting to and viewing a crystal report.Now I need to create a Property called DataSource. Crystal has a SetDataSource method that has 4 overloads/constructors(not sure what the right term is)1 accepts a System.Collections.Ienumerable, the 2nd accepts a Dataset, the 3rd a DataTable, and the 4th a DataReader.Now I want my property to be able to accept all those. So what Type must my property be.If I can just have DataSet and DataTable for now it would be fine, as I work with those mostly Public Property DataSource as?
View 3 Replies
ADVERTISEMENT
Jan 28, 2010
I have code running in the Datatable.ColumnChanging event in my dataset. This dataset underlies a form and conventional drag/drop controls are in place for data entry.when the event triggers and runs, I am running code in the form that checks the dataset.HasChanges property. It is showing False. But this is immediately after the ColumnChanging event has been triggered.Okay, I see by others posts and MSDN that .HasChanges will only be true after moving off the row with the changed column. I have also noted lots of discussion about the advanced binding property of DataSourceUpdate Mode, but that does not address this issue.I guess I can do this by checking the state of the row for the binding source. Just seems odd that the event behind the dataset can be triggered and that does not change the dataset.HasChanges property.
View 3 Replies
Sep 29, 2011
I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.
Public Sub Import(ByVal clsB As clsBatch)
Try
Me.cv_clsB = clsB
[code]....
View 5 Replies
Mar 23, 2010
VB.NET is not letting me dance with both feet, or piss with both hands. I've got one foot and one arm tied behind my back at every turn. I want to use this statement in a function:
Return CType(Formatter.Deserialize(FS), DS)
Seems doable, right?
Function ReadFileStream(ByRef FS As FileStream, ByRef DS As Object)
Dim Formatter As New BinaryFormatter
FS.Position = 0
Return CType(Formatter.Deserialize(FS), DS)
End Function
Right? I mean, CType only accepts a class name as the second argument. I can't give it an instance of a class, or it croaks. Yet if I try to pass the class name as the argument to that function:
DataInfo = ReadFileStream(FileStream1, DataStruct)
VB.NET croaks on this, too, complaining that "'DataStruct' is a type and cannot be used as an expression.". It's used as an expression by CType just fine outside of the function. Does the VB.NET legislature provide a clause that allows for a 'Type' to be passed as an argument in a function? Writing all the supporting code ten million times to deserialize a file using CType ten million times in a large application will get very complicated and tricky very quickly. It should be handled by a routine so that any cases and adjustments that come up can be dealt with in one spot.
View 8 Replies
Nov 18, 2009
I've been using VB for some time now, but I must admit I am a little confused. I started learning with 2002, then 2003, 2005 and now 2008. I think database coding must have been going through a kind of transition when I was trying to teach myself the basics. As a result, I am not entirely clear on a few things..
1) What's the difference between a DataTable and a DataSet. Why would I use one over the other?
2) Personally I dislike using DataAdapters etc and much prefer typing my connections in code so I can see what's what. When using the visual tools things are 'hidden' from view and it's not clear what's going on - do others find the same or is this just me being old fashioned?
3) Using my code-based approach (ie: creating SQL connection, using ExecuteNonQuery and a SQLDataReader to read the results into my application) - is this less efficient than the alternative methods?
4) Finally...LINQ. Is it any better and should I be using it as standard practice?
View 3 Replies
Jan 19, 2009
I am developing a Windows-application - database mssql - visual basic.I add Datasets to forms, bind them to daatagridview/textboxes - fill with dataadapter - everything's fine so far.
Here's my question:how do I programmaticaly move from a record/datarow i a dataset to another.I know the value of the key-field and want that record to be shown. If I use the dataset.datatable.findbykey-method, the program finds the record, but it doesn't move there.
View 5 Replies
Mar 15, 2010
When the user clicks an "Edit" button on my form, I want a box to come up which allows the user to edit a DataTable in a strongly-typed DataSet. What's the best way to do this?
View 2 Replies
Mar 15, 2010
I have a datatable and I apply a filter to the defaultview.rowfilter property of that datatable. If I then loop through the rows collection of the datatable, will I only be able to see those rows that the filter applies to, or will it loop through all the rows?
View 6 Replies
May 20, 2011
I have a datagridview bound to a datatable setting its datasource property to the datatable. I would like to have a child form that contains a list of columns associated with the datatable that contains a checkbox that will allow the user to hide and show the columns ( I do not know the best control to use here) (I assume this is the easy part as All i need to do is loop through each of the datatable's columns to get the column name)
now I would like save these visible columns on some event like form_closing so that the next time the user opens the form up it will remember the settings
View 5 Replies
Oct 31, 2010
how to copy data from datatable to table in dataset i ry this but its readonly property
ds.datatable1=newdt.copy
View 1 Replies
Sep 29, 2011
I have a datatable being returned by my DAL. In my BAL I want to return a class object. So I have a class called BusinessArea that has ID, Description and Active properties. I tried this:
[Code]...
View 2 Replies
Aug 7, 2009
How do I set a property from within the class it is defined in?
View 2 Replies
Sep 11, 2009
How can i make one item in my class not serialize?
I have tried adding:
<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)> with no avail
View 2 Replies
Dec 9, 2011
I have a class with many properties to which I need to assign values.I have another class with a sorted list of data from which the assignments are to be made. Is there a way to get the names properties from a class and refer to those properties?I looked through System.Reflection.Assembly but could not find a way to do it.
Class DataMngr
Sub ManageData()
Dim sl As SortedList(Of String, Double)
sl = GetData()
[code]....
View 4 Replies
Jul 12, 2009
I've got this in a public module
Module PublicModule
Public caseBAL_C As caseBAL
Public clientBAL_C As clientBal
Public Enum CSFlags
[Code]...
It doesn't like the Public Property StateFlag() As CSFlags -it's saying that CSFlags
'StateFlag' cannot expose type 'PublicModule.CSFlags' outside the project through class 'caseBAL'.
View 2 Replies
May 6, 2010
I have a collection class, say ITEMS, that inherits a Dictionary (of String, SINGLEITEM). From the SINGLEITEM class, I would like to reference a property in the parent ITEMS class, what is the best way to do this? For example, say the ITEMS class has an IsDirty property and I would like to set that if ANY of the contained SINGLEITEM objects is modified, what's the best way to go about doing this?
I know I could add a reference to the collection class in each SINGLEITEM class (since I override the ADD method, I could make this assignment), but this seems like overkill.
View 1 Replies
Jul 29, 2009
I'm creating a UserControl that draws a simple radial gauge. I need it to be very customizable; the user should be able to customize everything such as the colors, fonts, sizes. So, I just made a property for every customizable detail. For example, I had ScaleFont, ScaleColor, ScaleStart, ScaleEnd, ScaleInnerRadius, ScaleOuterRadius, ScaleTickmarkFrequenty, etc.. etc.. etc...
Because there are so many properties about the same subject, I wanted to 'group' these properties into one "property". I've seen this done loads of times in third party controls, but I've never done it before myself.The idea is that the properties can be accessed like
Me.Gauge1.ScaleSettings.Start = 10
Me.Gauge1.ScaleSettings.End = 80
...
So far, I tried creating a class for each group, for example a clsScaleSettings class, containing properties like Font, Color, Start, End, InnerRadius, OuterRadius, TickmarkFrequenty, etc (corresponding to the same properties as above).
Then, for every 'group' or class, I create a Property. For example, I have the ScaleSettings property, which simply returns an instance of the clsScaleSettings class (I initialize the instance only once of course):
vb.net
Private _ScaleSettings As New clsScaleSettings
Public Property ScaleSettings() As clsScaleSettings
[code]....
Now, this works in the code editor. I can now use
Gauge1.ScaleSettings.Font = Me.Font
for example, and it sets the font correctly.But, I does not work in the designer, in the Property Grid. The whole reason I made the effort to move and rename nearly all properties (about 70!), and all references to those properties, to separate classes, was so that the user could design the gauge more easily using the Property Grid!Instead of having 15 settings related to the scale, scattered all over the Property Grid, he can now have one ScaleSettings property, which he can expand, and then he can edit the properties of that group easily.The ScaleSettings property is greyed out in the property grid... So I cannot expand it and view it's underlying properties.
View 16 Replies
May 3, 2012
I'm writting a class that needs the form handle but there is a way to use it without send it as argument in the class constructor or in a property?I know that the handler is not set until the form is completely loaded so that is another problem too.The basic idea is catch the form handle without pass it as argument and handle the wm messages.
View 2 Replies
Jun 1, 2012
I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.
My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:
Public Class ResourceItem
Public ID As Integer
Public Text As String[code]....
As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.
UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.
View 2 Replies
Jul 21, 2010
How do i search a dataset or datatable for a record by entering 3 values in the search. If the row exists, I want to amend some of the data in that row?
View 1 Replies
Apr 1, 2010
I need some help to understand my options to get this working. I try to update a textbox control by a property-changed event from a class variable. I've digged around for a day and have a vague understanding that this can be solved in three ways:
1. Using some "if InvokeRequired", "Invoke" code in the handler method
2. By programming a special delegate class for this variable
3. By using a databinding directly linking the control (textbox) to the class event
Now.. Are these options correct? And would it be possible to get some help to show these three solutions in actual code (relevant to mine)? I can't seem to manage to sort all the information to a working code. Also, what are the pros and cons of the different solutions?
As my code stands now, it's obviously none of the above, as it gives a cross-thread error, as indicated.
[Code]...
View 2 Replies
Aug 13, 2009
I have the following code:
Public Class MyColorsClass
'Constructors
Public Sub New()
'Empty Constructor
[code]....
However, if the empty constructor was called to instatiate this class then the colortype is not yet set. Therefore, if one accesses the 'IsColorCool' property it will always return 'False'. Now for the sake of this example, I must keep the empty constructor as part of the class.Now I could add some code in the 'IsPropertyCool' to check and see if a ColorType has been defined, and throw an exception if it has not been set, but I don't really want to do that.I also could always move the logic OUT of the property and into a method on the class called 'DefineIfColorIsCool' or something, and make the owness on the caller to make sure the method was called if they want to use the property 'IsColorCool'?
View 5 Replies
Mar 12, 2009
I'm trying to create a program which accepts a letter of the alphabet. For each letter a corresponding word beginning with that letter should be output, e.g., �a� or �A� input would give Alpha as the output, �b� or �B� would give Bravo and so on to �z� or �Z� giving Zulu.So if the user enters: "abc" for example, what should happen is a list on the right of the window appears with the words starting with those letters when the user presses calculate.I don't have any code apart form the basics below.
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
[code]....
View 7 Replies
Apr 7, 2011
Supose a base class
Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer
[code]....
Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?
View 2 Replies
Nov 14, 2009
I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]
View 1 Replies
Mar 30, 2010
This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.
Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent
Some example code (hopefully formatted correctly):
Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass
[Code].....
View 7 Replies
Apr 2, 2010
I'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.
View 4 Replies
Jul 29, 2010
I have build a datatable in vb
dim Booking_table as datatable
Is it possible to add this datatable to a dataset or do I have to build in acces2007 and import in VB.
View 1 Replies
Nov 4, 2010
I have a strongly typed dataset and datatable and I am trying to do an add row.
Dim newDT As New hdar.AccessRequestsDataTable
Dim newRow As hdar.AccessRequestsRow = newDT.NewAccessRequestsRow
newRow.Number = nextNumber
newRow.RequestedByID = Me.cboUser.SelectedValue
newRow.RequestedOn = Date.Now.ToShortDateString
[Code] .....
View 3 Replies
Apr 27, 2012
i am using Microsoft.Office.Interop.Excel to read the data from excel,
--Students_Table--
id_S | Name | Sex
12 john M
[code]....
-----the table where uploaded excel file saved--
id_u | id-S | Scor |
1 12 30
i want to get the Id_S from "John"(excel file), i tried using the dataset with query
select Id_P from Students_Table where (Name =: Name)
and then check fillBy & GetBy my vb code :
Dim ta As New Students_TableAdapters.StudentsTableAdapter
Dim DataID as Integer
if ta.fillBy(ExlRead.Value) <> 0 then
[code]....
i use breakpoint to check those and i found an error message
"ORA-01722: invalid number"
(i'm using oracle database)if i pointed my cursor to the ta.fillBy it shows Public Overridalle Overload Function FillBy(Name as string) as decimal?
View 1 Replies