use of the shared function, which returns a reference to a datatable to the calling code. While there a probably many debates as to the preferred use of ADO.NET objects, my question is about the Shared Method aspect. Note that the dataTable is declared within the Shared Function, so it seems to me you get a new one every time, yes?
Public Shared Function MyData() As DataTable
Dim ReturnData As New DataTable
'A silly example of retreiving some data into a datatable:
Using cn As New SqlClient.SqlConnection("SomeCOnnectionString")
Inside my .aspx I have some JSON code that looks like this:
[Code]....
Basically what I'm doing is pulling text from two labels on one page, and sending them to another page by calling the "doIt" function which looks like this:
[Code]....
Just so I'm clear, the "doIt" function and the JSON call are on two separate web forms. My problem is that with the "doIt" function being Shared, I can't access any global variables of the class. And if I remove the Shared, my JSON doesn't execute.
It works, when I make getBar methods public, but I don't want to expose these unneccessarily. Why I can't call private shared methods from a public one in the same class is over my head. I'm using .net framework 4.0 in a web application.
Given in the following language specification, for me at least, calling Db.Foobar() [In the following code] does not indeed call off to the Shared Constructors of the base classes. I am curious as to a) is this my own fault for doing something wrong or b) is this an error in the language specification[code]...
As the question states, can a shared method of an object be multithreaded? I don't quite having threading down in my skillset, otherwise I would test myself. On the other hand, I am involved in designing class that could be part of a multithreaded application in VB.Net.
I have a class that inherits from a base class (this contains a lot of common db related stuff amongst other things and is marked as MustInherit). I want to write a shared method in which I call a base class method, however the compiler gives me the message 'MyBase is only valid within an instance method'. This shared method is a logging method and will be used a lot within the app, I'm trying to avoid having to instantiate an object each time I want to call it.
Is it possible to access the base class methods from a shared method?
I have a utility class that creates & returns a db connection: Public Shared Function GetConnection() as OracleConnection dim c as New OracleConnection() ... set connection string... c.Open() Return c End Function Is there any risk of concurrent calls returning the same connection? The connection string enables pooling.
I'd like to export a table from Access to a text file (or a spreadsheet) using VB code in Excel 02. I'm using the transfertext command but my code runs through without actually doing anything or throwing up any errors. If I swap the code round and change Export to Import and move the data into the text file manually then the code will happily import the table into Access.
Sub Export() dbfile = "C:XLSMDBTable.mdb" Dim a As Object Set a = CreateObject("access.application")
I have a new developer that is calling Showdialog (in VB.NET) on a Windows Forms form without first creating an instance of the form.How is this possible? I don't see a shared method for ShowDialog...
I'm not crazy about this approach either as it seems to me that the dialog will not be disposed until the application exits.What am I missing? Is this a new best practice?OK, Form2 is just a blank form.Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click Form2.ShowDialog() End Sub End Class
I'm creating a Shared (static) method in ASP.NET MVC so it can be used by any controller in my project. This static method needs to generate a URL. I think I need to use System.Web.Mvc.UrlHelper, but I can't figure out how to call it from within a static method.The constructor seems to want a RequestContext.
I like to create an extension method to Image.FromStream Public Shared Function FromStream(ByVal stream As System.IO.Stream) As System.Drawing.Image
With possibility to cancel processing like Public Shared Function FromStream(ByVal stream As System.IO.Stream, ByVal CloseTask As ManualResetEvent) As System.Drawing.Image
I have been thrown in at the deep end with an existing VB.NET project at work. I have never used VB.NET before so I am struggling a little. Does anyone know how to solve the following.I need to pass an instance to client side and then pass it to a shared method in order to access instance methods from when the shared method.The starting point is a fileupload control within the HTML of my Contacts.aspx file:
The onchange event calls a javascript method, see below, this uses AJAX PageMethods to called a Shared method in my code behind This is the script code which is in my Contact.aspx file
[Code]...
If anyone knows the solution please could they update the code as I probably won't be able to understand if you just give a description. I just hope I am along the right tracks.
I have a base class with several derived classes. I want all of my derived classes to have the same Public Shared (static) method with their own implementation. How do I do this? Is it even possible?
There is a popup window which is rendered using xslt (no aspx page) on click of button, during this window load and close events I need to manipulate the text exist in the textarea of popup window. Having said I need to store the list words (key,value) for validation and spell check so I just declared a dictionary/hashtable object in common class (globals.vb) where i could store (add and retain values until I click close window, there could be couple of in turn calls to other methods of popup window) and manipulate as expected but whenever I reset the dictionary/hashtable (objDic.clear()) on popup load and close, it resets the concurrent users dictionary also.
Note : 1.Dictionary is declared as Public in Public Module (Globals.vb). 2.Dictionary manipulation happens inside the shared method (that is in turn calls to shared method of popup events).
(I tried with this question but this code isolates the problem better. I have this code:
Public Shared Sub PopulateTextFields(ByRef stuffList As List(Of Stuff)) Dim aStuff As New Stuff For Each aStuff In stuffList DoStuff(aStuff) Next End Sub
I have created a shared add-in in Visual Studio 2008 and using the shared add-in wizard and am coding in VB. When run the add in in Access 2003 I want to check if the user has a database open, so I set a AccessApplication variable to be the application object in the OnConnection procedure and then on a button click I check if AccessApplication.CurrentDB Is Nothing If there is no database open Access will close correctly after the button is clicked. But if a database is open then I have to stop Access in the VS debugger.
If I have a very large function/sub in a class that is an instance method (i.e., not Shared), do I gain or lose anything by moving that to a shared method and then declaring a small stub method for the instance use?
I.e., I go from this: Public Sub MyBigMethod(ByVal Foobar As String) If String.IsNullOrWhitespace(Foobar) Then Throw New ArgumentNullException("Foobar") End If [Code] .....
My thinking is I save on memory size per each instance of the object. Because each instance only has to lug around the stub method which handles calling the shared version and passing an instance of itself to the shared method so that it can do whatever it needs to do. But I'll wager that I sacrifice a very teensy amount of speed because of the added function call overhead.
[code] I'm trying to post data on these two TextBoxes using HttpWebRequest method , Blow is the post data string [code] So when i send this request to the website , It only post the password but not the name , There's something causing conflict with the word name either 'name="name"' this line or something else.
I have a simple multithread application that stores updated data from a list of websites. After each thread gathers data, it then store the data into the same text file. I am now thinking of having each thread store the data directly into a arrayList, and after a certain amount of time past, store from the arrayList to the text file. Which situation would enable the application to complete its task faster?
I would like to know the best, or standard, way to accomplish real-time client updates in a small multi-user application using an access data table as a data source.Specifically, this application will be used by 3-4 people. It uses a datatable which is filled on form load and bound to a datagrid at design time. The datatable is stored on a shared drive. The data table on the shared drive is updated in two ways:
1) Users can update the datagrid which then updates the datatable on the shared drive via the data adapter's Update method.
2) A server application does some work on some text files, periodically updating the data table.
I need the clients to reflect the changes to the data table on the shared drive as closely to real-time as possible. I know that the data table stored in memory on the client is disconnected from the data table on the shared drive, so I must query again to get the updates.
1) Is there an alternvative model I can use which is connected, and which will automatically reflect the updates in the data table on the shared drive?
2) If not, what is the best way to check for changes in the data table (so I can know when to call the data adapter fill method)? I am planning to poll the drive for a change to the .mdb file, raise an event and then fill the data adapter when the event is triggered. I am using this method successfully now to check for changes to a text file in another application, and I know how to implement it?
I would like to know the best, or standard, way to accomplish real-time client updates in a small multi-user application using an access data table as a data source.
Specifically, this application will be used by 3-4 people. It uses a datatable which is filled on form load and bound to a datagrid at design time. The datatable is stored on a shared drive. The data table on the shared drive is updated in two ways:
1) Users can update the datagrid which then updates the datatable on the shared drive via the data adapter's Update method.
2) A server application does some work on some text files, periodically updating the data table.
I need the clients to reflect the changes to the data table on the shared drive as closely to real-time as possible. I know that the data table stored in memory on the client is disconnected from the data table on the shared drive, so I must query again to get the updates.
I have two questions:
1) Is there an alternvative model I can use which is connected, and which will automatically reflect the updates in the data table on the shared drive?
2) If not, what is the best way to check for changes in the data table (so I can know when to call the data adapter fill method)? I am planning to poll the drive for a change to the .mdb file, raise an event and then fill the data adapter when the event is triggered. I am using this method successfully now to check for changes to a text file in another application, and I know how to implement it
I've used .NET for a long time but I've never really been sure of this warning :-"Access of a shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated"Whilst this is not causing an issue and I've not really experienced this problem a lot with my own code, converting some code from an old .NET project gives 10's of these errors.
Code: Protected Function GetContentTypeFromString(ByVal TypeString As String) As MailContentType Select Case TypeString.ToLower
After I formatted my laptop and reinstalled Visual Studio 2005, I receive a lot of same error as below message. "Access of shared member through an instance; qualifying expression will not be evaluated" If I click the error, it direct me to the line and all 102 error suggest me to add "Windows.Forms." before "DialogResult.OK". Should I add something on "Reference"?