|
|
Hi Guys. I am running an export from my db to csv. I would like to populate the Exported Column in the DB with a 'Y' to show that the record has been exported. Can somebody please tell me how I can do this? Below a snip of the export code. Also, if I do this, how do I only export records that are marked as N in the ["Exported"] Column in the table?
private void toolStripButton2_Click(object sender, EventArgs e)
{
StreamWriter sw = new StreamWriter(@"C:\nefz.csv", false);
DataTable dt = m_dtCallCentre;
int iColCount = dt.Columns.Count;
for (int i = 0; i < iColCount; i++)
{
sw.Write(dt.Columns[i]);
if (i < iColCount - 1)
{
sw.Write(";");
}
}
sw.Write(sw.NewLine);
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i < iColCount; i++)
{
if (!Convert.IsDBNull(dr[i]))
{
sw.Write(dr[i].ToString());
}
if (i < iColCount - 1)
{
sw.Write(";");
}
}
sw.Write(sw.NewLine);
}
sw.Close();
}
I would like to enhance this to search for value 'N' in ["Exported"] column, export the record and change the value to 'Y'.
Any help with this would be greatly appreciated.
|
|
|
|
|
Hi,
Can you describe a little bit about table structure i.e. columns, keys etc, you want to export?
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
Hi. Exporting the data is fine. What I want to do is mark a specific column in the Table with a Y once the record has been read by the StreamWriter. The export routine is in my original post.
|
|
|
|
|
Hi,
How can I calculate the size of the parameters that I supply to a web service method?
thanks,
- ferudun
|
|
|
|
|
I want to keep the values in "frog" readonly. However, for some reason I'm not being allowed to set these values in my constructor, even though the error reads:
A readonly field cannot be assigned to (except in a constructor or a variable initializer)
*Note: {{ and }} replace angle brackets, which HTML can't handle
public struct foo<br />
{<br />
public readonly List{{frog}} al;<br />
<br />
public struct frog<br />
{<br />
public readonly int legs;<br />
public readonly int eyes;<br />
}<br />
<br />
public foo(int unususedInt)<br />
{<br />
al = new List{{frog}}();<br />
frog myFrog = new frog();<br />
myFrog.legs = 2;<br />
myFrog.eyes = 2;<br />
al.Add(myFrog);<br />
}<br />
}
What am I doing wrong, and how can I implement this?
|
|
|
|
|
JoeRip wrote: public foo(int unususedInt)
{
al = new List{{frog}}();
frog myFrog = new frog();
myFrog.legs = 2;
myFrog.eyes = 2;
al.Add(myFrog);
}
It looks like you have the legs and eyes fields on your struct set as readonly. I doubt the error you're encountering is being generated from writing to the list, but instead setting the properties on the frog instance. Hope this helps.
|
|
|
|
|
Sorry, I misread the first time....
Since those fields are readonly in addition to your list, you need to set them in the a constructor of the frog struct. You might try adding something like the following to your frog struct.
public frog(int legs, int eyes)
{
this.legs = legs;
this.eyes = eyes;
}
so your entire program would look like....
public struct foo
{
public readonly List<frog> al;
public struct frog
{
public frog(int eyes, int legs)
{
this.eyes = eyes;
this.legs = legs;
}
public readonly int legs;
public readonly int eyes;
}
public foo(int unususedInt)
{
al = new List<frog>();
al.Add(new frog(2, 2));
}
}
Hope that solves your prob. Sorry it took me twice to get the problem.
|
|
|
|
|
Interesting, I'll try this. Thanks for your help.
Man, I have to get a better grip on the difference between the instance data and the... uh, non-instance data. Apparently all of my questions about using a struct come down to this.
|
|
|
|
|
I have a problem while using MDI childs in DOTNET C#. On may MDI Parent when one child is maximized all chileds are maximized. But i want to stop some forms from maximizing.
Can any one help me
|
|
|
|
|
Hi..
I am using ASP.NET 2.0 +C#. In my webpage, I have a listbox. I have declared the listbox as shown below:
<code> <td align="center" valign="middle" style="width: 160px">
<asp:ListBox ID="lstPickAvillQueue" runat="server" Height="120px" Width="144px">
</asp:ListBox></td></code>
I want to provide a horizontal scrollbar so that long names can be easily seen. How to provide the horizontal scrollbar to the listbox?
Thank You
Venkat
|
|
|
|
|
Hi..
I checked the code project articles. One author had suggested to use the <div> tag with Overflow:Auto .
I Have changed the code as below. Is this proper?
<code> <tr>
<td align="center" valign="middle" style="width: 160px">
<div style="Height:100px;Width:200px;Overflow:Auto">
<asp:ListBox ID="lstPickAvillQueue" runat="server" Height="120px" Width="144px">
</asp:ListBox> </div></td>
</tr></code>
Thanks & Regards,
Venkat
|
|
|
|
|
Hi,
I am using GridView of WPF.
I need to show horizontal and vertical grid lines.
Please help
|
|
|
|
|
Could anybody give me some idea on how to provide security in remoting.
Thanks & Regards,
|
|
|
|
|
Ah, structs. God love them. Because I can't.
Why am I getting the compiler error:
Field 'foo.myInts' must be fully assigned before control leaves the constructor.
For this code:
public struct foo<br />
{<br />
public readonly List{{int}} myInts;<br />
<br />
public foo(int unususedInt)<br />
{<br />
List{{int}} myInts = new List{{int}}();<br />
myInts.Add(1);<br />
}<br />
}
Where {{ and }} are really angle brackets, but HTML can't handle that.
If it's complaining about the Default Constructor - well, I don't have any control over that, and I have no idea how the compiler is intializing myInts. And in the public constructor, I am clearly assigning myInts.
What exactly is it complaining about?
|
|
|
|
|
public struct foo<br />
{<br />
public readonly List myInts;<br />
<br />
public foo(int unususedInt)<br />
{<br />
List myInts = new List();<br />
myInts.Add(1);<br />
}<br />
}
only two letters away from being an asset
|
|
|
|
|
Thanks. It took me a second to see what you had changed . I was about to reply with "Ummm... what?"
Man, I wish the compiler error was less ambiguous here. It seems more like the foul was declaring myInts twice, not that it was unassigned.
|
|
|
|
|
JoeRip wrote: seems more like the foul was declaring myInts twice, not that it was unassigned.
No, the problem was that the member variable was unassigned. You created an instance that was scoped only to the constructor.
only two letters away from being an asset
|
|
|
|
|
But shouldn't there have been a name collision? The name was already declared as a field, and accessible at the constuctor level.
|
|
|
|
|
The variable in the constructor is scoped locally and overrides the one declared at the struct level.
It is a good practice to use properties to access member variables, and not make them public. Also, the practice of naming members variables with either m_ or _ (underscore) would alert you to this type of error.
only two letters away from being an asset
|
|
|
|
|
Can any one tell me how to run an EXE through windows service.
Thanks in Advance.
|
|
|
|
|
What do you mean? Do you mean how to create a Windows service, or do you mean how to run an exe from a Windows service?
only two letters away from being an asset
|
|
|
|
|
How to run an exe from a windows service?
|
|
|
|
|
Have you had a look at Process.Start method ?
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
use System.Diagonistic and create a process class object and give thhe process file name as your exe and start it !!!!
|
|
|
|