|
Hi all,
I have created a scheduling service which runs all the time, I am having a query regarding following set of code.
private DataSet GetDataSet()<br />
{<br />
<br />
DataSet excelDataSet = new DataSet();<br />
OleDbConnection excelConnection = new OleDbConnection(myConnectionString);<br />
OleDbCommand excelCommand = new OleDbCommand(@"SELECT * FROM " +fileName, excelConnection);<br />
OleDbDataAdapter excelAdapter = new OleDbDataAdapter(excelCommand);<br />
<br />
excelConnection.Open();<br />
excelAdapter.Fill(excelDataSet);<br />
<br />
if (excelConnection.State == ConnectionState.Open)<br />
excelConnection.Close();<br />
<br />
return excelDataSet;<br />
}
Do I need to call dispose on OleDbDataAdapter and OleDbConnection connection object to avoid memory leaks or garbage collector will take care of this?
Regards,
Prakash Kalakoti
|
|
|
|
|
Though the GC would collect all of the allocated managed memory periodically, its best to dispose off the DB objects when you are done. Your code should have been in the lines of :
using(OleDbConnection excelConnection = new ...)
{
etc etc
}
|
|
|
|
|
I recently downloaded and was interested in using the OrderedDictionary class but can't seem to index items because it doesn't inherit OrderedList. It does Implement COllection though and I would assume I would be able to index an item but no go, can't index the values or Keys. Anyone had any luck with this? Is there another library in the PowerCOllections that will allow you to find an item by either the Index or Key?
Thanks,
Santiago Perez
Regards, Santiago "Saint" Perez Florida's Turnpike Enterprise Santiago.perez@dot.state.fl.us
|
|
|
|
|
I have an application that is organized like below: (top to bottom)
COMenabled.EXE
OCXControl.ocx
DLLLibrary.dll (linked statically with a managed C++ wrapper)
NETLibrary.dll (C# DLL)
(other C# DLLs)
So basically, the COMenabled.EXE has a reference to the OCXControl, which links to the DLLLibrary, which in turn links to the NETLibrary, and so on down the line....
I have a problem where if I do not place the COMenabled.EXE in the same directory as the OCX control, it gives me an exception trying to load the NETLibrary.DLL. If I put it in the same directory, it then works.
I do not have any config files for any of the DLLs or EXEs.
Also, I do not load any of the DLLs into the GAC either. The same problem listed above occurs even when I load NETLibrary.dll into the GAC.
Can anyone give me suggestions as to what the problem is and how to solve it?
Thanks,
David
|
|
|
|
|
I am about to embark on a complex mechanism for instantiating hierarchical sets of remotable classes to handle Marshal-By-Reference and Marshal-By-Value remoting.
The reason for this is to enable the client to be able to continue working disconnected from the server should a server fail for some reason.
To keep it simple the model I am considering involves the server objects switching between MBR and MBV.
Anyone done this before and knows of a simple way to do this without having to reconstruct the objects on the server?
|
|
|
|
|
Andy,
Am not clear on your requirement. Do you have a web service or a remoting host which exposes the object to the client? Not sure why the client cant just work off the serialized object?
|
|
|
|
|
Hi Nitin,
Thanks for your reply.
I am trying to create remoting objects that can be referenced on a server when in a particular, if you like 'chatty', role but also the same objects having the capability of being serialized onto the client is in another role where they are connected to heavy weight data processing.
An example: Supposing you have a Person object that is connected to security logon - Person in this role would not need to be serialize and Marshal-By-Reference would suffice. However, the same Person object could also be associated with a Product, Order, Patient and Medical information later in a process and involved with longer and heavier processing where the lifetime of the object on the client may even span several sessions - here Marshal-By-Value is probably best. However the Person object is the same - I was hoping to find a way to initially use a Person object reference on the server and transfer/serialise that same Person object to the client without having to construct a new Person and copy data across.
Bearing in mind that there will be many such objects, one of the main reasons therefore is to try and reduce server processing of these objects, and also could be useful to be able to cache state and behaviour on clients for cross session reasons.
I hope that makes sense?
Andy
-- modified at 12:15 Friday 29th June, 2007
|
|
|
|
|
Andy,
From what I follow, you need a mix of MBR, MRV. For this, I can only think of creating a MBR descendant object which implements ISerializable (or mark as Serializable). This way, you start with an MBR object on the server and when the client requests for the instance (perhaps identified with an Guid?), the server serializes the object and returns it.
But, do note that MBV is usually recommended only for light weight objects.. since the whole object is being passed across.
Thanks,
Nitin
|
|
|
|
|
Yes thanks Nitin. I am also looking at customised serialisation too - I've got some learning to do in this area.
I will try what you suggest and I am aware of the size limitation for MBV - the idea is to serialize pieces of the object model to and from the client and not the whole thing in one go, but do this only where necessary and only for writeable objects.
I know there are a whole load of data integrity issues too but that another story.
Andy
|
|
|
|
|
Once i convert the Winhelp to Html Help i am able to get only the .htm and .hhk files. I am not able to get the .hhc(contents file).Does the file size matter while converting or could there be any other problem??????
ASHA
-- modified at 4:45 Wednesday 27th June, 2007
ASHA
|
|
|
|
|
We store our source code in MS SourceSafe. For common classes and functions we are not sure where to store the .dll for access by other applications etc. For example we have a database class that connects to any of the corporate DBs...
Any one have any architechture ideas
|
|
|
|
|
tri595 wrote: For common classes and functions we are not sure where to store the .dll for access by other applications etc.
Keep those DLLs in GAC.
|
|
|
|
|
Thanks... we keep the source code in MS SourceSafe and we wanted to put the Dlls in a secure location for access by another application.. they will be in the GAC when we deploy the application anyhow.. what benefit does this give?
|
|
|
|
|
|
I have Created A ListBox Control Whose Handle is Desktop.
My code for ListBox:
#using <mscorlib.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System:ata;
using namespace System:rawing;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
namespace DeskTopTest
{
///
/// Summary for MyListBox
///
// Requires unmanaged code
[assembly: SecurityPermissionAttribute (SecurityAction::RequestMinimum, UnmanagedCode=true)];
// Requires ability to create any window type
[assembly:UIPermissionAttribute(SecurityAction::RequestMinimum, Window=UIPermissionWindow::AllWindows)];
public ref class MyListBox : public ListBox
{
public:
MyListBox(void)
{
}
protected: virtual property System::Windows::Forms::CreateParams^ CreateParams
{
virtual System::Windows::Forms::CreateParams^ get() override
{
const int WS_EX_TOOLWINDOW = 0x00000080;
const int WS_EX_NOACTIVATE = 0x08000000;
const int WS_EX_TOPMOST = 0x00000008;
try
{
System::Windows::Forms::CreateParams ^p =ListBox::CreateParams;
p->ExStyle |= (WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST);
p->Parent = IntPtr::Zero;
return p;
}
catch (Exception^ e)
{
return nullptr;
}
}
}
public:[DllImport("user32.dll")] static int SetParent( IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")] static int ShowWindow( IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")] static IntPtr GetDesktopWindow(void);
public: void ShowFloating()
{
if (this->Handle == IntPtr::Zero)
{
ListBox::CreateControl();
}
//IntPtr s=GetDesktopWindow();
int x=SetParent(ListBox::Handle, IntPtr::Zero);
x=ShowWindow(ListBox::Handle,1);
}
protected:
virtual void WndProc(Message% m)override
{
ListBox::WndProc(m);
}
};
}
but when i Added this listbox to my form like:
MyListBox ^lst=gcnew MyListBox();
lst->Location=System:rawing::Point(264, 166);
lst->Name = L"comboBox1";
lst->TabIndex = 1;
lst->Visible=false;
lst->Size = System:rawing::Size(171, 200);
for (UInt16 i=1;i<100;i++)
{
lst->Items->Add("Item"+i.ToString());
}
lst->ShowFloating();
and calling the function ShowFloating();
It is working fine.
But I cant unable to focus On my Listbox & cant able to use my mouse events.
I want to focus on listbox.
Plz Suggest me .........
Thanks in advance
Nagaraju
|
|
|
|
|
Hi,
I'm writing a C# windows application program that needs to connect to the SQL server 2000 or SQL 2005. What i want to do is when the user selects to connect to the server, a pop-up window appears that opens the data connection wizard where the can go through the wizard and connect to the sql servers are any other servers. Is this possible? If so, can someone please tell me how to do this?
|
|
|
|
|
Prompt the user for the server,Database,username, password. Prepare the connection string internally, connect using SqlConnection.
For enumerating the list of database, servers, use DMO or the new variant SMO
|
|
|
|
|
Hello,
Do you know a good resource which would describe possible situations that can leed to memory leaks? such as eventhandlers to objects that are no more needed and forms that aren't disposed after closing. Any article that would describe such situations and how to prevent them? Thanks
|
|
|
|
|
The only resource I know of is experience, or the tried and true technique of "trial and error".
|
|
|
|
|
Dave Kreskowiak wrote: The only resource I know of is experience, or the tried and true technique of "trial and error".
Know that feeling :->
|
|
|
|
|
Dave Kreskowiak wrote: The only resource I know of is experience, or the tried and true technique of "trial and error".
So you say that there is not any article in the internet on that subject?
|
|
|
|
|
|
originSH wrote: He's saying he doesn't know of one.
Thank you!
|
|
|
|
|
np
|
|
|
|
|
Hello,
How can I build a IP lan scanner in .net(vb.net/c#)?
It should give the list of all computers/devices in the network, and their relative IPs and (eventually) MAC Address and device/computer name.
Thanks in advance,
Carmine,
Webmaster of: www.thetotalsite.it
My web blog: blog.thetotalsite.it
|
|
|
|