|
I try not to make assumptions.
|
|
|
|
|
No.
byte b = 55 ;
System.Text.StringBuilder sb = new System.Text.StringBuilder() ;
foreach ( char c in b.ToString() )
{
sb.Append ( System.Convert.ToString ( c - '0' , 2 ).PadLeft ( 4 , '0' ) ) ;
}
System.Console.WriteLine ( sb.ToString() ) ;
|
|
|
|
|
Hi,
I have a simple method that checks if a sheet name is present in the excel file or not. The code is simple and works fine when the sheet name doesn't contain any spaces:
private bool validateExcelSheetByName(string name, OleDbConnection connection) {
bool result = true;
try {
if (connection.State == ConnectionState.Closed)
connection.Open();
var command = new OleDbCommand(string.Format("select * from [{0}]", name), connection);
command.ExecuteNonQuery();
}
catch {
result = false;
if (connection.State == ConnectionState.Open)
connection.Close();
}
return result;
}
In case I have a dot and a space in the sheet name (for example 'My. Sheet'), I get an exception saying:
Invalid bracketing of name 'My. Sheet$'.
I store the sheet name in a variable:
private const string sheetName = "My. Sheet$";
How can I fix this code so it will work when I have dots and spaces in the sheet name?
Thank you!
Andrei
|
|
|
|
|
You can use this code to get the schema.
DataTable dt = oCon.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
Here, datatable will have a column table_name which contains names of all the sheets in the file.
Hope it helps
|
|
|
|
|
This doesn't help me much... I have multiple sheets in the document and after I see that a certain sheet is present I have to process it:
var command = new OleDbCommand(string.Format("select * from [{0}]", sheetName), connection);
var adapter = new OleDbDataAdapter {SelectCommand = command};
var ds = new DataSet();
adapter.Fill(ds);
connection.Close();
DataTable dt = ds.Tables[0];
foreach (object dr in dt.Rows) {
string[] array = Array.ConvertAll(((DataRow)dr).ItemArray, new Converter<object,>(Convert.ToString));
// continue processing here...
}
So I would still have problems in the case of a sheet name that contains a dot and a space as mentioned in my initial post.
Is there any workaround for this issue?
Thank you!
|
|
|
|
|
Hi everybody
How can i define a variable that i can use it in two different forms.
for example
i want to define a variable like
string word = "Hi";
then i can write this code in a button in the second form
MessageBox.Show(word);
Thanks everybody
Hi everybody
How can I define a variable that I can use in two different forms?
For example
I want to define a variable like
string word = "Hi";
Then I can write this code in a button in the second form
MessageBox.Show(word);
Thanks everybody
|
|
|
|
|
You can create a class and define this variable as constant.
public class Messages
{
public const string Word = "Hi";
} use it like
MessageBox.Show(Messages.Word);
|
|
|
|
|
But what if I don't need the variable as a constant
For example I have a Textbox on Form1 and its name is TextBox1, and I want it like that
string word = TextBox1.Text;
Then I can show this text stored in the variable (word) in a Message Box in the second form.
Thank you so much
|
|
|
|
|
|
Create a static class and put your string variable as a static variable in this class.
This will allow you to share value of string variable between different forms.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|
|
(IMO) That's bad design man. Better is to have properties (or get/set methods as some don't like properties)
|
|
|
|
|
Hello Everybody! I'm making a program which can read RSS file on the internet.I want to display the content of tag title such as [ &quot;Hello&quot; ] on the ListView , but the ListView only displays ["Hello"] . How to make it display [“Hello”]? Using a replace method to replace &quot; to " in the content of tag title or existing another method ? Thanks for reading!
modified on Thursday, July 17, 2008 3:01 AM
modified on Thursday, July 17, 2008 3:02 AM
|
|
|
|
|
You'll need to set the ListView control's font to one that supports open and close quotes and replace the "e s with these characters.
/ravi
|
|
|
|
|
Oh I forgot to check "Ignore HTML tags in this message (good for code snippets)" for above post.
@Ravi Bhavnani: I tried to change ListView control's font but the problem wasn't solved.
modified on Thursday, July 17, 2008 3:31 AM
|
|
|
|
|
Hi all,
I am working on a application that is using WCF service. and on backend it has DB2
so when ever i am trying to retrive the records more then 1200 it fails...
i have set readerQuotas maxArrayLength="5000000" but still am getting timeout error when trying to retrive more 1100-1200 records
please suggest me here .. how can i retrive all records in one go .. without changing the time out setting from DB2
..
Thanks
Vikas
vikas da
|
|
|
|
|
One more thing i forgate to tell that i am displaying the records to the grid...so before displaying the records so while reading the records i kept a condtion there like
if(i==1800)
{
break;// a breakpoint is there
}
its reaching to the break point but not able to disply ...
please help me here
vikas da
|
|
|
|
|
Hi,
i am using a tool freely available on net called as IMacros.
It's a plugin which gets available as a toolbutton upon installation.
I want to create such application.
So i would be glad if anyone can provide me with how that can be achievable.
Thanx in advance
|
|
|
|
|
Please read this
http://www.codeproject.com/KB/security/encryption_decryption.aspx
What should I pass to the public methods as Source and Key.
I am just trying to encrypt the password
please let me know
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
Why not post your question in response to that article? Then the author can help you out directly.
Life, family, faith: Give me a visit.
From my latest post: "We are Christian, resistance is futile. Your Jewish traits will be assimilated into the Church collective."
Judah Himango
|
|
|
|
|
What is the best object in C# to create a board game (like chess, colonization, civilization)?
Datagridview? (i only use it to get sql data)
Panel?
400 PictureBoxes?
|
|
|
|
|
Use a 2d drawing API and do the board yourself in those constructs. I'd recommend Microsoft's XNA framework.
Life, family, faith: Give me a visit.
From my latest post: "We are Christian, resistance is futile. Your Jewish traits will be assimilated into the Church collective."
Judah Himango
|
|
|
|
|
I use a big bunch of buttons... kinda like MineSweeper. But only when appropriate; chess or checkers could be done that way.
|
|
|
|
|
Hello, All!
How can I get standart Windows XP Time Zone map? Is it COM-object? How can I use it? Or I must implement it custom?
Thanks, for help...
|
|
|
|
|
Hi all,
I do have lots of dlls saved in one folder and the new dll will be added to the same folder frequetly.
I also have a program, myProgram, that needs to reference all dlls in that folder.
Inorder to use the functions/methods of a dll, we have to
1) add Reference to myProgram,
2) using mydll;
3) create the instance and call the appropriate function.
So how can I add the reference and import the dlls as the program click on Button so I can use functions from those dlls.
or is there any other ways that myProgram to find out if there is new dll in the folder and start using it without recompliing myProgram.
|
|
|
|
|
Hi,
if your source code is referring to managed code that resides in some DLL, then you need to add
a reference, and you may choose to (or not to) use a using statement, in order to tell the compiler
how to find the types you are using.
if on the other hand you want to use types from some DLL files using reflection only, then no
reference and no using statement is needed pointing to these DLL files; with the right code
you can discover and use any managed DLL you can reach. Look for "reflection" on CodeProject or Google.
|
|
|
|