|
Hi All !
I want to Export my dataset to a Text File With This Format :
000010103327742000000000002477000000000000000000
000020103545843004000000002477000000000000000000
000030103362063008000000002500000000000000000000
000040205918898005000000002477000000000000000000
that :
00001 is Row of Person
0103327742000 is Account Number
000000002477000 is the their Money
and other number:
000000000000000 is nothing
my code for this is :
int i;
String strDestinationTxtFile;
strDestinationTxtFile = "C:\\output.txt";
StreamWriter sw = null;
sw = new StreamWriter(strDestinationTxtFile, false);
foreach (DataRow row in dsBankPardakht.Tables["PersonPardakht"].Rows)
{
object[] array = row.ItemArray;
for (i = 0; i < array.Length - 1; i++)
{
sw.Write(array[i].ToString());
}
sw.Write(array[i].ToString());
sw.WriteLine();
}
sw.Close();
the problem is how can get this format( for Rows , moeny and Account Number and ...)
Thanks for any Help
|
|
|
|
|
Use String.Format()[^] to ensure your output fields are in the requisite format, rather than ToString() .
|
|
|
|
|
Thanks for your Reply , but I couldn't Use this correctly:
for (i = 0; i < array.Length - 1; i++)
{
sw.Write(array[i].ToString());
}
sw.Write(array[i].ToString());
Can you explain more about this
Best Regards !
|
|
|
|
|
Go to the link I posted, and study the String.Format() method, to see how it can produce the information in the format that you want. Since I have no idea what format your original data is in I cannot give a specific example.
|
|
|
|
|
Richard MacCutchan wrote: I cannot give a specific example.
C'mon! Give example code, it's urgentz!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks a Lot !I use String Format and It's Works !
|
|
|
|
|
Hi,
I am new to Linq and I'm trying to access the MfgNumber after the query directly without a foreach loop. I don't need the foreach loop as the SQL query should be returning one result.
[Table(Name = "Mfg")]
public class Mfg
{
[Column(IsPrimaryKey = true)]
public string MfgName;
[Column]
public string MfgNumber;
}
...
var q2 =
from mfg in db.Mfg
where mfg.MfgName == Common.productPublisherName
select mfg;
foreach (var mfg in q2)
MfgNumber = mfg.MfgNumber;
How do I access the variables from the query without a foreach?
Thank you,
Glenn
|
|
|
|
|
This should meet your needs:
var q2 = from mfg in db.Mfg
where mfg.MfgName == Common.productPublisherName
select mfg.MfgNumber;
foreach (var string mfgNumber in q2) {
....
} I just re-read your post and realized you expect there to be (at most) one entry, so Mark's answer is the one you want.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: foreach (var string mfgNumber in q2) {
The OP did say without for loop
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: The OP did say without for loop The loop in my response processes the returned data - it doesn't extract it.
/ravi
|
|
|
|
|
The only thing your code does different from the OPs is return a single property of the object rather than the object as a whole. LINQ queries are not executed until requested such as when the GetEnumerator method is called in a for each statement. So, yes your statement does extract the data, then processes it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I just re-read the original post and realized he expects only one entry. My bad.
/ravi
|
|
|
|
|
Use Single if the query will return a single result. q2 will be of type Mfg
var q2 =(from mfg in db.Mfg
where mfg.MfgName == Common.productPublisherName
select mfg).Single();
or in case the query returns nothing create an object with default values, or null.
var q2 =(from mfg in db.Mfg
where mfg.MfgName == Common.productPublisherName
select mfg).SingleOrDefault();
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
In the main form, the button is disable that, after fulfilling the conditions in the external class must activate the button. can you help me? Thanks so much for all the advice. Mark
|
|
|
|
|
|
Hi,
I have a C# program (Green10) that runs fine on most every computer I've tried it on. But it doesnt run properly on a new computer I got.
I've downloaded and installed the .NET frameworks.
Any ideas what else it could be?
Thanks,
Green Lamar
www.GreenProductionss.com
modified on Friday, August 5, 2011 3:03 PM
|
|
|
|
|
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Security settings, maybe?
And like Griff said, edit your post and get rid of that e-mail address, or you'll get spammed.
|
|
|
|
|
HighlanderGreen wrote: But it doesnt run properly
Might help to specify exactly what that means.
|
|
|
|
|
What do you mean by properly?
Is really slow and sluggish?
I downloaded it for curiosity and it's really slow and sluggish on 16 GB RAM and iCore7 980.
Is your new computer running Windows 7 64 too?
Maybe this is the problem. I saw a LOT of interop(office and not only) files in there. That might be the cause.
All the best,
Dan
|
|
|
|
|
I've not noticed it to be slow on any machines.
Anyway, my main focus in these posts is figure out why it doesnt run on some machines.
Does everything seem to work on your machine?
I need to be sure it tuns on others machines.
Thanks a bunch,
Green
www.GreenProductionss.com/C_samples.html
|
|
|
|
|
I have two DataGridViewComboBoxColumns in a DataGridView. Column 1 contains {"A", "B", "C"}. The contents of column 2 should depend on the value displayed in the Column 1 cell in the active row; if "A" is displayed, Column 2 should contain {"1", "2", "3"}; if "B" is displayed, it should contain {"4", "5", "6"}; if "C" is displayed, it should be {"7", "8", "9"}. The change in display should be immediate; i.e., when "A" is selected, Column 2 should immediately display "1" - I shouldn't have to click on another cell to cause the change. How can I do this?
Basicly when I make a selection in one combobox (i.e the one in row 1) then I want the corresponding combobox in row 2 (same row) to update its content immediately. At the moment the update of content only happens once I click somewhere else in the datagridview.
any suggestions
|
|
|
|
|
I've got a bit of brain freeze going on...
I've got an array of control locations (a result of a layout process), and the bounding rectangle is something like -2000, -4000, 2000, 4000...I need to translate these locations so that they can be drawn on a panel control. I don't need them to 'fit' in the panel, i.e. scroll bars are acceptable.
Ideas???
|
|
|
|
|
I'm not sure I understood the question correctly. If you have a control you can add it to your panel and set the Location property to 0,0 (in Forms), that should set that control to the upper left corner. You can calculate the following control's Location with the Height and Width properties of the previous control.
Is this what you want?
V.
|
|
|
|
|
ah no, I've got a set of locations but if I were to directly add them to the panel they would be outside the bounds, clientbounds I think.
The locations were set it via in a unrelated coord space, I need to translate these cords so that they will be visible on the panels left/top 0,0 coord space.
I don't think it's a simple PointToClient/PointToScreen type thing...or at least I couldn't get that to work.
I think I need to use Point.Offset, but its working out the offset values that I'm struggling with.
Or maybe there's an alternative, can I change the panel's bounds? So that its the same as the bounds of these locations?
So my controls are in a rectangle (-x, -y, w, h), and I thought if I just move each location by +x1,+y1 then that should mean they would be visible on the panel which would be (0,0,pw,ph)
does that make any sense???
|
|
|
|