|
That gives "110111", not "01010101".
|
|
|
|
|
I think that he meant 0x55.
If you want it padded with zeroes, use the PadLeft method:
Convert.ToString(Temp, 2).PadLeft(8, '0')
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
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...
|
|
|
|