|
|
|
I suggest using the Jet Engine and ADO.net to access the XLS file directly rather than using CSV.
|
|
|
|
|
I believe Jet is not supported on 64 bit windows.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It is for 32 bit programs.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
How can I save the StackTrace into mySQL? is't too long for varchar? should I use TEXT?
Thanks.
|
|
|
|
|
type text is very good for holding text.
|
|
|
|
|
The stack trace can be huge, I've had problems with it truncating in the past. You might want a squizz at this[^] if you are using SQL 2005.
|
|
|
|
|
Are you planning on running the application that you're getting the stack trace from as a release build without the pdb files? If you are, you aren't going to get a useful stack trace I'm afraid.
|
|
|
|
|
A stack trace without line numbers is still a valuable information when analyzing errors reported by "real users".
|
|
|
|
|
I have lot of parameters in my paramTable in my SQL server and I need to read those parameters when the user login and keep it there then delete it when logout or just leave it and replace it when use login again on the same machine..
which way is best to do it? saving in in HashTable? or save in the App.config?
|
|
|
|
|
Hello Jrahma,
in my opinion the best way to go is to create a class where all the parameters are stored.
Using any ORM tool like NHibernate you can store it and retrieve it from a DB.
If you choose to store it elsewhere like in a file you can serialize / deserialize it with
say an XmlSerializer.
Cheers
Manfred
|
|
|
|
|
this is what I am currently doing... what do you think?
public void get_system_properties()
{
try
{
_system_parameters_hash = new Hashtable();
_system_parameters_hash.Add("SQL_SERVER_CONNECTION", null);
_system_parameters_hash.Add("SQL_SERVER_DATABASE", "Cure");
_system_parameters_hash.Add("EVENT_LOG_DESCRIPTION", null);
_system_parameters_hash.Add("SYSTEM_LOG_FOLDER", null);
_system_parameters_hash["SYSTEM_LOG_FOLDER"] = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + Application.ProductName + @"\";
_system_parameters_hash["SQL_SERVER_CONNECTION"] = "Data Source=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLServer").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";initial catalog=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLDatabase").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";User Id=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLUser").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Password=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLPassword").ToString();
_system_parameters_hash["SQL_SERVER_CONNECTION"] += ";Connection Timeout=";
_system_parameters_hash["SQL_SERVER_CONNECTION"] += cure_registry_current_user.GetValue("SQLTimeout").ToString();
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_get_system_parameters", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_reader = sql_command.ExecuteReader();
while (sql_reader.Read())
{
if (_system_parameters_hash.ContainsKey(sql_reader["system_param_name"])) return;
if (sql_reader["system_param_value"] == DBNull.Value)
{
_system_parameters_hash.Add(sql_reader["system_param_name"].ToString(), null);
}
else
{
if ((string)sql_reader["system_param_type"] == "bit") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToBoolean(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "string") _system_parameters_hash.Add((string)sql_reader["system_param_name"], (string)sql_reader["system_param_value"]);
else if ((string)sql_reader["system_param_type"] == "int") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt32(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "int64") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt64(sql_reader["system_param_value"]));
else if ((string)sql_reader["system_param_type"] == "short") _system_parameters_hash.Add((string)sql_reader["system_param_name"], Convert.ToInt16(sql_reader["system_param_value"]));
}
}
}
catch (Exception exp)
{
write_log("System", null, null, "Error populating system properties!!", exp);
MessageBox.Show("Error populating system properties!!" + Environment.NewLine + "Please contact your system administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
finally
{
if (sql_reader != null) sql_reader.Close();
if (sql_connection != null)
{
if (sql_connection.State == ConnectionState.Open)
sql_connection.Close();
}
}
|
|
|
|
|
jrahma wrote: HashTable
Do you mean a Dictionary?
I agree with Manfred; create a class. But I wouldn't have it done by a tool (not meaning you, Manfred); I'd craft one the way I want it. This is especially helpful if you use a Web Service in the future.
I'll also point out this[^] fine little article which may prove helpful.
|
|
|
|
|
hello i have a qns regarding progress bar.
i have a few loops how do i adjust the progress bar properties so that the progressing telly with my loops and not 100% after the loop had been carried out?
i use the following code:
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 100;
|
|
|
|
|
Is that what you want?
progressBar1.Minimum = 0;
progressBar1.Maximum = 100;
progressBar1.Value = 0;
for(int i = 0; i < 100; i++)
{
progressBar1.Value = i;
}
of if you have several loops:
progressBar1.Minimum = 0;
progressBar1.Maximum = 200;
progressBar1.Value = 0;
for(int i = 0; i < 100; i++)
{
progressBar1.Value = i;
}
for(int j = 0; j < 100; j++)
{
progressBar1.Value = 100 + j;
}
I know these are very simple examples, but actually threre's not much to it.
|
|
|
|
|
You should use a thread.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
when the main thread is executing an event handler (say a button click handler), it can't do anything else. That is why you can't move your window while it is calculating something, and why a progress bar sits idle too. The right solution is by hiring another pair of hands, i.e. a thread. This could be a Thread instance, a ThreadPool workitem, or a BackgroundWorker. For actions that need GUI feedback (such as progress reporting) a BGW often is the best choice. Make sure you read up about it and set its properties!
|
|
|
|
|
What the heck is a "qns"?? And are both your shift keys broken?
|
|
|
|
|
Hey, I have just published one article but, you know? It is about progressive operations, one-threaded and multi-threaded. Here is the link[^].
|
|
|
|
|
Hello! i'm a bit baffled when it comes to converting this javascript over to C#...
Any help would be appreciated! Thank you
Here is the javascript:
function d(strInput) {
strInput = decoder(strInput);
var strOutput = "";
var intOffset = (key + 112) / 12;
for (i = 4; i < strInput.length; i++) {
thisCharCode = strInput.charCodeAt(i);
newCharCode = thisCharCode - intOffset;
strOutput += String.fromCharCode(newCharCode)
}
document.write(strOutput)
}
And this is what i attempted at converting to C#.
public string decode(int key, string data)
{
int i;
string strInput = base64Decode(data);
string strOutput = "";
int intOffset = (key + 112) / 12;
for (i = 4; i < strInput.Length; i++)
{
char thisLetter = strInput[i];
char thisCharCode = strInput[i];
int newCharCode = thisCharCode - intOffset;
strOutput += new String(new char[]{Convert.ToChar(newCharCode)});
}
return strOutput;
}
|
|
|
|
|
Firstly user StringBuilder and use append method for adding strings. It will improve performance.
Second where is char thisLetter used?
Third what is the error you are getting?
Fourth why use Convert.ToChar when it already a character.
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
Well, i got it to work only when the key is a negative number.. For some reason it's still not able to convert when data is a positive number.
Example:
(int key = 212, string data = "U0lra36DfImFkImOkImCW4OKj4h8hIdJfoqI")
Output = {c¬a¬¬¬¬¬¬¬¬@¬¬¬¬a¬¬.c¬¬}
Example2:
(int key = -88, string data = "T1RXYmV0cHFkZ3R1MzQ1Ng==")
Output = {crnobers1234}
Code:
public string decode(int key, string data)
{
int i;
string strInput = base64Decode(data);
StringBuilder strOutput = new StringBuilder("");
int intOffset = (key + 112) / 12;
for (i = 4; i < strInput.Length; i++)
{
int thisCharCode = strInput[i];
char newCharCode = (char)(thisCharCode - intOffset);
strOutput.Append(newCharCode);
}
return strOutput.ToString();
}
|
|
|
|
|
Solved:
<pre>public string decoder(string data)
{
string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
char o1, o2, o3;
int h1, h2, h3, h4, bits, i = 0;
string enc = "";
do
{
h1 = b64.IndexOf(data.Substring(i++, 1));
h2 = b64.IndexOf(data.Substring(i++, 1));
h3 = b64.IndexOf(data.Substring(i++, 1));
h4 = b64.IndexOf(data.Substring(i++, 1));
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
o1 = (char)(bits >> 16 & 0xff);
o2 = (char)(bits >> 8 & 0xff);
o3 = (char)(bits & 0xff);
if (h3 == 64) enc += new string(new char[] { o1 });
else if (h4 == 64) enc += new string(new char[] { o1, o2 });
else enc += new string(new char[] { o1, o2, o3 });
} while (i < data.Length);
return enc;
}
public string d(int key, string data)
{
int i;
string strInput = decoder(data);
StringBuilder strOutput = new StringBuilder("");
int intOffset = (key + 112) / 12;
for (i = 4; i < strInput.Length; i++)
{
int thisCharCode = strInput[i];
char newCharCode = (char)(thisCharCode - intOffset);
strOutput.Append(newCharCode);
}
return strOutput.ToString();
}
</pre>
|
|
|
|
|
I'm having a little trouble here(i'm a beginner in C# btw). I can't seem to place the horizontal scrollbar in the listbox. When i insert the Hscrollbar to the listbox, it does not load into the listbox but only scrolls outside of the box. Hopefully you guys get what i mean. I need the scrollbar to automatically be enabled in the listbox whenever the texts exceed the width of the listbox. I have the vertical scrollbar automatically enabled already.
Oh and btw, i'm working on smart device application in C# language.
Any help?
Thanks!
|
|
|
|