|
Its a Windows service. And it does lot of operation hence I created a global connection.
Also I need to implement the Transactions between different methods which do different operation on database.
Please suggest what can be the good approach
Regards,
Pavas
|
|
|
|
|
ok i see why you went for a global then, cant say if that is still the best option but i dont know what exactly you are doing.
What difference do the methods have, do they need different commands?
if so you would change the global command with each method, so may as well just create the command you need in the method and pass to connection
|
|
|
|
|
each of the method have different sql operations and they insert records in the database.
My question is, I want an approch to implement the transaction.
Regards,
Pavas
|
|
|
|
|
All you need is the Connection and Transaction objects. You create the Transaction from the Connection, something like:
DbTransaction tran = conn.BeginTransaction();
Then, you can do everything off of these objects (create the commands from the connection, etc.); be sure to set the command's Transaction property approriately; so you'd have something like:
DbConnection conn = GetConnection();
DbTransaction tran = conn.BeginTransaction();
bool success = true;
...
success = MethodA(conn, tran);
success = success && MethodB(conn, tran);
success = success && MethodC(conn, tran);
if(!success)
tran.Rollback();
else
tran.Commit();
...
private bool MethodA(DbConnection conn, DbTransaction tran)
{
bool result = true;
DbCommand comm = conn.CreateCommand();
comm.CommandText = ...
comm.Transaction = tran;
...
return result;
}
...
private bool MethodB(DbConnection conn, DbTransaction tran)
...
private bool MethodC(DbConnection conn, DbTransaction tran)
...
If you want to make the Connection and Transaction objects class-level variables and have the methods access them that way instead of passing them in, is up to you; I just prefer this way.
Keep It Simple Stupid! (KISS)
|
|
|
|
|
This is of great help. I was looking for an approch like this.
Regards,
Pavas
|
|
|
|
|
Hi
I have to convert a pdf file into doc/word file with all the images and formatting preserved. Searched all the options,tried all the free libraries but nothing seems to be working.
Anyone having idea ??????????
Thanks
Don't walk as if u rule the world,walk as if u don't care who tha Hell rules the world ...
|
|
|
|
|
How do I do that? Did some google search but couldnt find any good result
|
|
|
|
|
ListView.Items.Count;
Are you sure you searched?
|
|
|
|
|
i did searched but i got results that were irrelevant. thanks anyway
|
|
|
|
|
how to give printing view ,to form in word formatting
|
|
|
|
|
Hi,
if you just want to print the form, have a look here:
http://msdn.microsoft.com/en-us/library/6he9hz8c.aspx[^]
But if you want a more sophisticated view (like Word) you should try sth called "report generator". There are several products like Crystal Reports, List Label (german) etc... Also some free generators are available.
Regards
Sebastian
|
|
|
|
|
Oh just an addition. There is a control called Report Viewer. This one can take files with the extension rdlc. If you open such a file in VS2008, then you can create a report. This means that VS has its own report generator out of the box.
Regards
Sebastian
|
|
|
|
|
Hi,
Where will i find caspol.exe for 64 bit?
Thanks in advance,
Regards, Subramanyeswari
|
|
|
|
|
|
|
Hi,
Do we need to make any changes or settings to use Signed DLLs in Windows Service? It is not working for me where as un-signed DLL is working fine.
Thanks in advance
|
|
|
|
|
try a simple test: ensure that there is no copy of your dll in the GAC, copy the fully signed dll and the exe into a new directory, then try to run the application.
Sathesh.
Blessed is the season which engages the whole world in a conspiracy of love.
|
|
|
|
|
public class clsRequestService
{
private static object _objArrayList =new object();
string _strUser;
string _strServiceRequested;
public object _ReqAL
{
get
{
return _objArrayList;
}
set
{
_objArrayList = value;
}
}
public string _User
{
get
{
return _strUser;
}
set
{
_strUser = value;
}
}
public string _ServiceRequested
{
get
{
return _strServiceRequested;
}
set
{
_strServiceRequested = value;
}
}
}
public static Collection<clsRequestService> ocRequestService = new Collection<clsRequestService>();
while (some thing)
{
oReqSer = new clsRequestService();
.....
oReqSer._ReqAL=ReqAL;
oReqSer._ServiceRequested = strReqServ;
oReqSer._User= strUser;
AppGlobalData.ocRequestService.Add(oReqSer);
}
Every thing works fine except the Array list, Latest array list values are duped in to
all the arraylist values in the collection.
How to make deep copy of array list
|
|
|
|
|
Hi,
what kind of object to you store within the arraylist? If it is a class of your own you have to implement the interface ICloneable. This will mark objects of this class as cloneable.
Then you have to implement sth to make a deep copy of your arraylist (Clone on ArrayList is not working since it only copies the reference of the contained objects). There you could have a look at this link
http://www.thomashapp.com/node/106[^]
Does this help you?
Regards
Sebastian
|
|
|
|
|
ptr_Electron wrote:
Every thing works fine except the Array list, Latest array list values are duped in to
all the arraylist values in the collection.
That's because clsRequestService is a reference type, so changing some values inside this class will be reflected in the second list. If you need a deep copy, then you must also provide a mechanism to clone objects of the clsRequestService type. There are various methods how to do this in .NET, you should take a look at this link[^] and some links inside this article.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi,
I have created a Windows Application that use Client Application Services for login purposes. Can someone please tell me how to deploy this service to a "Live" environment?
I have successfully packaged and deployed the Windows Application but obviously I cannot login as the web service is unavailable.
Thank you!
Illegal Operation
|
|
|
|
|
Hello,
I have 2 treeviews and one button. Ofter selecting a node in the first treeview and clicking the button, the selected node most be copied into the second treeview.
Bud how can i check first whether the second treeview already contains the selected node in treeview1?
Thanks,
Priya
|
|
|
|
|
Do you have a key or some kind of identifier that you're checking? Are you just checking the node text?
Generally speaking, you can use recursion to check each tree node with a boolean value for whether the node exists.
|
|
|
|
|
Just checking the node text
|
|
|
|
|
something like this
bool ContainsNode(string nodeText, Node treeNode){
if(treeNode.Text.Equals(nodeText){
return true;
}
bool contained = false;
foreach(Node node in treeNode.Children){
contained |= ContainsNode(nodeText, node);
}
return contained;
}
|
|
|
|