|
|
|
This reads it into a DataTable
public void CreateXLSDataTable( String fileName )
{
//DataTable tb = new DataTable("XLS");
dtXLS = new DataTable();
Excel.Application ExcelObj = null;
ExcelObj = new Excel.Application();
if ( ExcelObj != null )
{
Excel.Workbook empBook = ExcelObj.Workbooks.Open(fileName,0,true,5,"","",true,
Excel.XlPlatform.xlWindows,"\t",false,false,0,true);
Excel.Sheets empSheets = empBook.Worksheets;
Excel.Worksheet empSheet = (Excel.Worksheet)empSheets.get_Item(1);
bool lineValid = true;
int iCount = 1;
while ( lineValid )
{
iCount++;
Excel.Range range = empSheet.get_Range("A"+iCount.ToString(), "X"+iCount.ToString());
System.Array myvalues = (System.Array)range.Cells.Value;
string[] strArray = ConvertToStringArray(myvalues);
if(strArray[0].Equals("") )
{
lineValid = false;
continue;
}
if( iCount != 2 )
{
object[] objArray = strArray;
dtXLS.Rows.Add(objArray);
}
else
{
for(int i=0; i< strArray.Length; i++)
{
dtXLS.Columns.Add(strArray[i]);
}
}
}
}
else
{
Trace.WriteLine("Excel reading Error: could not load the excel file object");
}
ExcelObj.Quit();
ExcelObj = null;
}
private string[] ConvertToStringArray(System.Array values)
{
string[] theArray = new string[values.Length];
for(int i=1; i<=values.Length; i++ )
{
if( values.GetValue(1,i) == null )
theArray[i-1] = "";
else
theArray[i-1] = (string)values.GetValue(1,i).ToString().Trim();
}
return theArray;
}
public DataTable XLS
{
get
{
return dtXLS;
}
}
|
|
|
|
|
lets say I have an
object[] myObjects
once populated from a sqldatareader using getvalues method they can be tons of different ones
how do I use the typeof or different reflections methods to find what exact type it is to compare in a switch statement?
please help, I'm using string comparisons.
nick
|
|
|
|
|
object.GetType() should give you the information you require.
Rocky Moore <><
|
|
|
|
|
foreach (object o in myObjects){
if(o is string ){
...
}
else if(o is int ){
...
}
else if(o is ...){
...
}
...
}
I hope this helps
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
This snippet goes through the collection of objects and does a breakdown by type. This assumes that you have different processes you want applied to the data based on different data types that exist in the collection.
foreach (object item in myObjects)
{
switch (item.GetType())
case typeof(string):
{
...
}
case typeof(int):
{
...
}
...
}
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
|
You're welcome.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I'm using reflection to grab the type
propertyCaller.PropertyType.GetType()
I get this errpr "a value of integral type expected."
what gives? and why a integer type
|
|
|
|
|
what properties do I set if I have a class like
public class MyClass : CollectionBase, IBindingList, ITypedList, and a few more I cant remember
how od i do it?
|
|
|
|
|
Just started to read up on ADO.NET. Do I understand this correctly:
Normally, when I code a C++ app I open a connection or two when I first start my app. I keep the connection open until my app is closed. I would created and destroy command objects many times during the life of the app.
With ADO.NET am I supposed to call Close on the Connection after EVERY time I get done using it? - - Because there is a connection pool that it is returned too.
|
|
|
|
|
Yep, that is pretty much it. I think the connection pooling is more for ASP.NET but also think that when you are holding on to a connection, that is one more connection license being used on the server. If you happen to run against MSDE, there are only five I believe before it throttles down.
You have to use planning though, as there is an time overhead in establishing those connections depending on where the server is located.
Rocky Moore <><
|
|
|
|
|
I'm creating an exception manager for my application. When an unhandled application exception occurs the class needs to be able to send the report back to the company. I know about the System.Web.Mail namespace, but it looks like an smpt server is required, and it seems like win2k is also required. How can I send an email and have it work even on win98 without specifying an smpt server. Does the .net framework have a class that will send an email with its own smpt server.
|
|
|
|
|
AK wrote:
it work even on win95
You are asking the wrong group, .NET is not supported on Win95. You will have to choose another programming langauge.
Rocky Moore <><
|
|
|
|
|
I didn't know that .net framework didn't work on 95. I really don't care, as long as the majority of the windows users have support.
Anyway. Does the .net framework have a class that would send email with it's own smpt server?
|
|
|
|
|
You can use the built in routines or search CP for "SMTP C#", there are several aritcles with different methods.
Rocky Moore <><
|
|
|
|
|
.NET does have an SMTP server - nor should it. That's really not a "base class library" sort of thing. Windows Option Pack 4 introduced the SMTP services which provides CDO. The System.Web.Mail namespace has classes to use this (and doesn't have to be used from the Web, BTW), but the .NET class library doesn't.
The other poster is right - you can use sockets to do this, but it's not really a decent SMTP server unless you support more functionality. Hey, sounds like a great idea for a CP project! Good luck!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
What you are actually looking for is a SMTP client that will post your messages to a SMTP server at the destination server.
Actually, a good source for you could be at:
http://www.lumisoft.ee/lsWWW/ENG/index_eng.aspx?type=products[^]
Check out the e-mail server. It has full source code and you can probably strip out some client code to send your e-mails without the need of a SMTP server.
I have seen other code, but not sure where at the moment. I have been using the Lumisoft e-mail server (with a few modifications) for more than a year. He has done a great service for the .NET world providing a full SMTP/POP3 server that supports MIME and now authentication.
Rocky Moore <><
|
|
|
|
|
I'm developing a remote control software and would like to know if it's possible to compare between two images to check and see if they are the same image. For example, if i am idle while using the remote control software, the remote PC image would be the same at all times (until there are change on screen such as mouse movements, time updates (clock @ statusbar), etc).
If there's an alternative way or any suggestions, i'd be glad to hear it. The reason why i'm doing this is to prevent the server from sending the same image (screenshot) every time regardless of whether the user (on the client side) is idle or using the remote pc.
|
|
|
|
|
I would have thought the overhead in doing the comparison would be prohibitive.
This should be event based so that a new screen is only sent to the client when something happens that then need to be aware of.
If you really must do the comparison, its pretty easy to convert an image into a memorystream and then into an array where you could do a byte by byte comparison.
|
|
|
|
|
You could take a checksum of the image on both sides and compare the checksum.
|
|
|
|
|
somebody can help me , how to get all param in store procedure
ex : myStore(@param1, @pram2, @pram3,...)
and I want that
index name
1 @param1
2 @param2
3 @param3
....
thanks!!!
Nho'c ti`
|
|
|
|
|
sqlCOmmand.Parameters.Add("@param1", SqlDbType.Varchar,200);
sqlCOmmand.Parmaters["@param1"].Value = 1;
|
|
|
|
|
No, I want get name param of myStore
ex : Store Procedure myStore(@param1, @param2,...)
in this store : @param1, @param2 I don't know that name and I want get name of all param in this store
Nho'c ti`
|
|
|
|