|
Mogaambo wrote: each file have half million of records
I dont think you're going to find any particularly fast way, but the only option you have is to open each file, read its contents, and write whatever bits of it you want to the db.
|
|
|
|
|
Use streams. I usually prefer StreamReader.
DON'T use the static methods of the 'File' class. They are orders of magnitude slower than streams. To verify that just write a small benchmark app using a System.Diagnostics.Stopwatch to test the speed of various methods.
|
|
|
|
|
Mogaambo wrote:
So which is the fastest method, so that i write quickly to the db.
Find a big fly
|
|
|
|
|
It will stay pretty slow, but what you could do is: if a query fails, log it.
that way you can do those manually if necessary (after finding the error ).
|
|
|
|
|
If these files have an identifiable structure, and don't require lots of complicated transformations, you could always bulk import them using bcp (I'm taking a flyer here that you are using SQL Server), and a format file[^] to constrain what goes where.
|
|
|
|
|
Is Sqlbulkcopy is the feasible solution ??????
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Depending on the format of your files, yes. If your file doesn't have the data you need split over multiple lines, then it's extremely feasible.
|
|
|
|
|
+1 To BULK copy and format files.
|
|
|
|
|
We have this exact situation and use a combination of Bulkcopy for foxpro files and BCP for the text files. As Pete said you must have a consistent file structure.
We have one situation where the file structure changes, in this case we read in the first line of the text file, pass that string to a stored procedure which drops and creates the target table if the structure has changed. We then use BulkCopy to load the table. Caveat - make ALL your target fields varchar and do your transforms using the stored procedure called AFTER the bulkcopy.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: make ALL your target fields varchar and do your transforms using the stored procedure called AFTER the bulkcopy
Pretty much what I do too. I have a "raw" version of the table that's all varchar and a trigger to convert and move the data on to where it needs to be.
|
|
|
|
|
PIEBALDconsult wrote: and a trigger to convert and move the data
You will not find a single trigger in any database I have ever been resposible for, hate the bloody things. I remember the first time I ran across them, spent 2 days trying to find out why a process failed when I wasn't anywhere near the table that caused the error - bloody triggers
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I agree, but they seem a reasonable solution to the loading-via-bcp situation:
A one-line BAT file is all that's required to perform the load.
The whole operation is performed in a transaction, so if the data is invalid I'm not left with invalid data in the "raw" table.
|
|
|
|
|
I am using ClickOnce to run my windows application from web Page.
want to access querystinrg in windows Application, I am using the followung code for that :
public string GetQueryStringParameters()
{
NameValueCollection nameValueTable = new NameValueCollection();
string queryString = System.Deployment.Application.ApplicationDeployment.CurrentDeployment.ActivationUri.Query.ToString();
nameValueTable = HttpUtility.ParseQueryString(queryString);
return (nameValueTable.ToString());
}
But i am not getting the Querystring information.
Please Help.
|
|
|
|
|
|
Hello,
how can i avoid, that my Control (AutoScroll=true) everytime scrolls to the Coordinate (0,0) if it is repainting? I've tried it to save the actual Vertical and Horizontal Scroll-Value in a Variable, and after repainting, i set the Scrollbars to that value. But the problem is the Scrollbars doesnt jump to the right position, i see the controls correctly, but the scrollbars (the "really" visible scrollbars) doesnt change.
Can somebody help me?
|
|
|
|
|
Hi,
I am developing an application in C# that will retreive an email based on some search criteria in the subject line from a mail account and forward the retrived mail to different receipients along with a new a message on top of the forwarded mail.
How can i achieve below functionality in C#?
- How can i retrive a mail based on some search criteria?
- How the mail can be forwarded to other receipients along with the new message on top of that?
Kindly revert for any clarifications.
Thanks in advance.
Praveen Raghuvanshi
Software Engineer,
India.
|
|
|
|
|
praveen raghuvanshi wrote: How can i retrive a mail based on some search criteria?
Depends on what mail server you have. CP has an article[^] on getting mails from POP3.
praveen raghuvanshi wrote: How the mail can be forwarded to other receipients along with the new message on top of that?
Create a new mail message, append the existing message also to it's message body.
|
|
|
|
|
Thanks..
I tried the method described in the link provided earlier.
There is a table in the message which i want to forward.
I am not able to get the table in the table format in the body part of message. So when I forwards the message, table elements get displayed in the message and not the whole table in the tabular form.
Kindly advice to forward a table in the table format along with the text message.
Praveen Raghuvanshi
Software Engineer,
India.
|
|
|
|
|
I have a set of classes in an assembley.In each class there are certain methods.when I select assembly it should display all the classes in the grid view .when I select a class in the gird view it should expand the gridview and should display all the methods in the grid view as separate rows.
I am able to display classes in the grid view .when I select a class I am not able to expand the gridview to display the methods as extra rows.
I am able to display methods in separate a gridview ,but not in the same grid view.
please help in how to expand or collapse gridview to display classes/methods information in an assembly
Thanks for any help
|
|
|
|
|
Please post your code
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
This is the code i have written to display class/method details in separate grid views.
private void dllPathTextBox_TextChanged(object sender, EventArgs e)
{
int id = 1;
DataSet dataSet = new DataSet();
classesSummaryTable = new DataTable("ClassesSummary");
classesSummaryTable.Columns.Add("ID", typeof(int));
classesSummaryTable.Columns.Add("TypeName", typeof(Type));
classesSummaryTable.Columns.Add("Summary", typeof(string));
methodsSummaryTable = new DataTable("MethodsSummary");
methodsSummaryTable.Columns.Add("ID", typeof(int));
methodsSummaryTable.Columns.Add("MethodName", typeof(string));
methodsSummaryTable.Columns.Add("Summary", typeof(string));
Assembly asm = Assembly.LoadFrom(this.dllPathTextBox.Text);
Type[] classes = asm.GetTypes();
foreach (Type type in classes)
{
DataRow classSummaryRow = classesSummaryTable.NewRow();
classSummaryRow["ID"] = id;
classSummaryRow["TypeName"] = type;
string comment = new XmlComments(type).Summary.InnerText;
if (comment == "")
classSummaryRow["Summary"] = "No Summary For This";
else
classSummaryRow["Summary"] = comment;
classesSummaryTable.Rows.Add(classSummaryRow);
MethodInfo[] mi = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in mi)
{
DataRow methodsSummaryRow = methodsSummaryTable.NewRow();
methodsSummaryRow["ID"] = id;
methodsSummaryRow["MethodName"] = methodInfo.ToString();
string comment1 = new XmlComments(methodInfo).Summary.InnerText;
if (comment1 == "")
{
methodsSummaryRow["Summary"] = "No Summary For This";
}
else
{
methodsSummaryRow["Summary"] = comment1;
}
methodsSummaryTable.Rows.Add(methodsSummaryRow);
}
id++;
}
dataSet.Tables.Add(classesSummaryTable);
dataSet.Tables.Add(methodsSummaryTable);
DataRelation relation = new DataRelation("MethodsOfCLass",
dataSet.Tables["ClassesSummary"].Columns["ID"],
dataSet.Tables["MethodsSummary"].Columns["ID"]);
dataSet.Relations.Add(relation);
classesSummaryBindingSource.DataSource = dataSet;
classesSummaryBindingSource.DataMember = "ClassesSummary";
methodsSummaryBindingSource.DataSource = classesSummaryBindingSource;
methodsSummaryBindingSource.DataMember = "MethodsOfCLass";
}
I am binding that two binding source objects to two separate grid views to display in different gridviews.
This is the code i have written to display class/methods details in separate grid views.But i need to display in only one gridview.First i need to display only classes information.when user selects any particular class row then grid should be expanded and should display method information in the same gridview as separate rows.when user again selects the same class row gridview should be collapsed.
thanks for your response
|
|
|
|
|
Hey,
I'm trying to become familiar with programming with DirectX and I've got the graphics part working but for some reason MouseState.X and MouseState.Y always return 0;
My current setup is:
private Device mouse;
// initialization
mouse = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Mouse);
mouse.SetCooperativeLevel(this, Microsoft.DirectX.DirectInput.CooperativeLevelFlags.Background | Microsoft.DirectX.DirectInput.CooperativeLevelFlags.NonExclusive);
mouse.Acquire();
// Use
MouseState ms = mouse.CurrentMouseState;
Console.WriteLine("Mouse1 is down Point: {0}, {1}", ms.X, ms.Y);
The events for the mouse are working, it correctly detects when mouse 1 and mouse 2 are pressed, but ms.X and ms.Y are always 0. Anyone know what I'm doing wrong?
|
|
|
|
|
I need to get the network drives so I have chased through from the CreateObject in VB to ManagementClass C#. I snaffled the following code from MSDN
using System;<br />
using System.Management;<br />
<br />
class Sample_ManagementClass<br />
{<br />
public static int Main(string[] args)<br />
{ <br />
ManagementClass diskClass = new ManagementClass("Win32_LogicalDisk");<br />
diskClass.Get();<br />
Console.WriteLine("Logical Disk class has " + diskClass.Properties.Count + " properties");<br />
return 0;<br />
}<br />
}
My problem is System.Management does not have a ManagementClass it only has Instrumentation.
I am using VS2008
Any ideas on how to reference to the ManagementClass
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: I need to get the network drives
You need to query using ManagementObjectSearcher[^] class. This[^] shows an example.
Hope it helps
|
|
|
|
|
You need to add the REFERENCE for System.Management - Aaaahhhhh.
Never underestimate the power of human stupidity
RAH
|
|
|
|