|
Please don't spam the entire site, just ask the right person, in the right place.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i m little bit confused as i m new in this site ...
sorry...
|
|
|
|
|
Well, like I said, if it's an article, no-one here knows what you're talking about. There's a forum under the text of the article, post your article specific question there.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Here is an example of a use of the TransactionScope class:
using (TransactionScope ts = new TransactionScope())
{
SqlConnection myConnection = new SqlConnection("server=(local)\\SQLExpress;Integrated Security=SSPI;database=northwind");
SqlCommand myCommand = new SqlCommand();
myConnection.Open();
myCommand.Connection = myConnection;
myCommand.CommandText = "DELETE FROM Region WHERE (RegionID = 100) OR (RegionID = 101)";
myCommand.ExecuteNonQuery();
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (100, 'MidWestern')";
myCommand.ExecuteNonQuery();
myCommand.CommandText = "Insert into Region (RegionID, RegionDescription) VALUES (101, 'MidEastern')";
myCommand.ExecuteNonQuery();
myConnection.Close();
ConsoleKeyInfo c;
while (true)
{
Console.Write("Complete the transaction scope? [Y|N] ");
c = Console.ReadKey();
Console.WriteLine();
if ((c.KeyChar == 'Y') || (c.KeyChar == 'y'))
{
ts.Complete();
break;
}
else if ((c.KeyChar == 'N') || (c.KeyChar == 'n'))
{
break;
}
}
}
The above piece of code is taken directly from MSDN. At one point, if the user answers 'Y', the ts.Complete() method is called, which makes the Dispose() method commit the transaction (or rollback it if the user answers 'N').
How is the SqlConnection instance associated with the TransactionScope ? Is this magic happening under the hood?
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Hi,
you can spend a lot of time and money, and have great fun not collecting stamps;
Of course it is a hobby.
|
|
|
|
|
Then I am not collecting a lot of things. I a man busy with millions of hobbies. I don't where I can find time to ask questions about TransactionScope
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Hello,
What I understand from the docu, it is really defined by the code-block, and it is recommended to use an using-block!
Le Centriste wrote: Is this magic happening under the hood?
I would say yes, MS magic!
All the best,
Martin
|
|
|
|
|
There's no magic, the using statement creates a code block which ends in calling Dispose, you can use this with any object that impliments IDisposable.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I don't think that this was the question, or at least I understood it different!
All the best,
Martin
|
|
|
|
|
Hi Christian
I was asking how does the TransactionScope instance is associated with the SqlConnection instance.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
There's nothing magic about it at all. You are seeing the behaviour because of a "hidden" connection string entry - Enlist. If Enlist is true then the SqlConnection will automatically enlist in the enclosing scope. Obviously, this only applies to Sql Server (2005) connections as the Sql Server (2005) data provider automatically checks (based on the Enlist) whether or not there is an open transaction to work under.
|
|
|
|
|
Ok, thanks, that is the answer I was looking for. I remember now from the documentation that the Enlist parameter defaults to true in the connection string, for the SQL Server 2005 provider.
Have a nice day.
-----
If atheism is a religion, then not collecting stamps is a hobby. -- Unknown
|
|
|
|
|
Hi Le Centriste,
I think the magic here is that System.Transactions uses COM+/Enterprise Library under the hood to enlist the SQL commands in a distributed transaction, and SQL knows this through the enlist parameter in the connection string. When Complete() is called, the transaction is committed, and if Dispose is called without a Complete() call, the transaction is rolled back.
*edit* oops, I see Pete already answered your question
|
|
|
|
|
Hello everybody,
I had an mdi from having an toolStrip on the click event of toolstrip button i want to close all the opened child form but i am unable to do so.
Regards,
rahul saini
|
|
|
|
|
Have you tried calling Close() on all forms in your Mdi Form's MdiChildren ?
Standards are great! Everybody should have one!
|
|
|
|
|
hi,
I've tried the following code at http://www.msnewsgroups.net/group/microsoft.public.dotnet.languages.csharp/topic6944.aspx
i've made the changes they say, but it still doesn't work when i insert a usb device (flashdisk).
I'm trying do detect when a device is inserted into a usb port. how can i do it? and if possible, which port it was inserted at. it's for a WPF app
EDIT: ok, it's working now, but i have the same questions that the person with the code posted:
1)Check if the device is inserted or removed..How do i do that??
2)also i want to check Total storage (capacity)of the device connected
c) storage(unused)available in the device
thanks donovan
-- modified at 6:54 Thursday 12th July, 2007
rather have something you don't need, than need something you don't have
|
|
|
|
|
Maybe this can help you http://www.codeproject.com/cs/system/DriveDetector.asp ?
As for storage Use GetDrives() function to get all drives and identify the drive you are interested in. Then you can use DriveInfo functions to get necessary information
|
|
|
|
|
Hello,
I'm using System.Management functionality for that!
WqlEventQuery q_creation = new WqlEventQuery();
q_creation.EventClassName = "__InstanceCreationEvent";
q_creation.WithinInterval = new TimeSpan(0,0,2);
q_creation.Condition = @"TargetInstance ISA 'Win32_DiskDriveToDiskPartition'";
mwe_creation = new ManagementEventWatcher(q_creation);
mwe_creation.EventArrived += new EventArrivedEventHandler(USBEventArrived_Creation);
mwe_creation.Start();
internal void USBEventArrived_Creation(object sender, EventArrivedEventArgs e)
{
}
WqlEventQuery q_deletion = new WqlEventQuery();
q_deletion.EventClassName = "__InstanceDeletionEvent";
q_deletion.WithinInterval = new TimeSpan(0,0,2);
q_deletion.Condition = @"TargetInstance ISA 'Win32_DiskDriveToDiskPartition' ";
mwe_deletion = new ManagementEventWatcher(q_deletion);
mwe_deletion.EventArrived += new EventArrivedEventHandler(USBEventArrived_Deletion);
mwe_deletion.Start();
internal void USBEventArrived_Deletion(object sender, EventArrivedEventArgs e)
{
}
For checking the free and available space:
public void Hashtable GetFreeDriveSpace()
{
Hashtable drivefreespace = new Hashtable();
ManagementClass mcDriveClass = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection mocDrives = mcDriveClass.GetInstances();
foreach(ManagementObject moDrive in mocDrives)
{
try
{
String sDeviceId = moDrive.Properties["DeviceId"].Value.ToString();
double dSize = double.Parse(moDrive.Properties["Size"].Value.ToString());
double dFree = double.Parse(moDrive.Properties["FreeSpace"].Value.ToString());
}
catch
{
}
}
mocDrives.Dispose();
mcDriveClass.Dispose();
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
thanks to both of you, seems both solutions would be able to solve my problem!
thanks again
donovan
rather have something you don't need, than need something you don't have
|
|
|
|
|
Hi frinds,
My Question is simple. How to convert the CSV file to XLS file using the C# Programming langueage.
Thanks,
Liyakhat.
|
|
|
|
|
You can use the Excel Application object Microsoft.Office.Interop.Excel namespace...
|
|
|
|
|
Hi Bijesh,
First of all thanks, I got the code to Convert CSV file to XLS file using Excel Application object.
My code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using Microsoft.Office.Interop.Excel;
namespace File_Conversion
{
class Program
{
static void Main(string[] args)
{
ApplicationClass app = new ApplicationClass();
Workbook doc = app.Workbooks._Open(
@"C:\GCProject\Input Example.csv",
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
false,
Missing.Value,
Missing.Value,
false);
Console.WriteLine("Reading CSV File........");
doc.SaveAs(
@"C:\GCProject\Output.xls",
XlFileFormat.xlWorkbookNormal,
Missing.Value,
Missing.Value,
Missing.Value,
Missing.Value,
XlSaveAsAccessMode.xlExclusive,
Missing.Value,
false,
Missing.Value,
Missing.Value,
Missing.Value);
doc.Saved = true;
Console.WriteLine("Converted CSV to XLS file");
app.Quit();
Console.ReadLine();
}
}
}
But Now, I have to get specified format, Like.
My CSV file Contains Data like.
-----------------------------------
Ex: DriverID | CustomerID | Ship to ID | Load # | BOL Date/TimeStamp |PrdNam
520 | 2355 - | 1 | 61953 | ############ | 1 Eth 87
My XLS file Contains Data Like.
-----------------------------------------------------------------------------
Ex: Field | Definition | Length | Starting Column | Ending Column |
-----------------------------------------------------------------------------
delimiter"
-----------------------------------------------------------------------------
TransType|Some Definition |1 | 1 | 1
|
-----------------------------------------------------------------------------
delimiter ","
-----------------------------------------------------------------------------
Termin ID | Some Difinition| 3 | 3 | 5
|
-----------------------------------------------------------------------------
delimiter ","
-----------------------------------------------------------------------------
Term SPLC | Some Difi | 7 | 6 | 12
|
-----------------------------------------------------------------------------
I got the code converting CSV file to XLS file. But What I need is Converted
XLS file should look like above format in Converted Excel sheet.
Hope I explained well.!
Thanks in advance.
Regards,
Liyakhat.
|
|
|
|
|
try using Google[^] - the first result gives you a full code example of the answer to your problem
|
|
|
|
|
|
Christian answered this question for you when you asked it yesterday and Jamie answered it the day before. Please don't repost questions.
You need to understand that people here will normally give you the hints/areas that you need to look at in order to complete your task. They will not give you the complete application. You are expected to do some work on your own, and having been told to look at office Interop it is not unreasonable to think that you will have used <<insert search="" engine="" of="" choice="" here="">> to research the topic. If you have a problem with code then tell us what you have done, where the problems are and what they are. At that stage, we will be able to provide more help.
|
|
|
|
|