|
Thank you Giorgi, but, could you be more specific and give me an example?
|
|
|
|
|
I gave you a link to documentation. Did you have a look at it? There is an example.
|
|
|
|
|
Hi Giorgy,
The link you gave me is about registry (Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^]),as far as I can figure it out.
Sorry, but I can't see the answer to my question in this article.
I'll give you more details about my question.
Suppose I have a class Person:
class Person
{
string FirstName;
string LastName;
int Age;
...Some methods
}
All I want is to get those fields names (FirstName, LastName and Age) and put them in a list of strings.
Also, if it's possible to get default values for those fields that would be great(to me) to know too!
Best Regards, matixsc
<div class="ForumMod">modified on Tuesday, November 4, 2008 7:07 AM</div>
|
|
|
|
|
matixsc wrote: The link you gave me is about registry (Asynchronous Registry Notification Using Strongly-typed WMI Classes in .NET [^]),as far as I can figure it out.
Sorry, but I can't see the answer to my question in this article.
That's the link in his signature, click the link ABOVE his signature.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thank you everyone! I think this should help.
|
|
|
|
|
I have a string containing Chinese character (double byte), how can I tell if this string are in Chinese characters?
S Wong
|
|
|
|
|
Strings are always in Unicode, so you will have to probably get the UnicodeCategory for each character, and check that.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks for the hint, leppie
I used the following code to solve the problem as my string is either
in English or Chinese only:
string cde = "some double byte characters";
char ch = cde[0];
UnicodeCategory cat = char.GetUnicodeCategory(ch);
if (cat ==UnicodeCategory.OtherLetter)
// Chinese character logic
else
// English character logic
S Wong
|
|
|
|
|
Hi.
I get this error in the name of the tiopic.
Details JIT debugger:
System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Studenti_Ure.frmUrce.button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\milos\My Documents\Visual Studio 2008\Projects\Studenti-Ure\Studenti-Ure\Form1.cs:line 147
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I have a .mdb access database with two tables ("ure" and "uporabniki).
The code in C# looks like this:
string strSQL = "INSERT INTO ure(username,mesec,dan,ure,minute,komentar) VALUES('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')";
strSQL = string.Format(strSQL, login.uporabnik, dateStart.Value.Month.ToString(), dateStart.Value.Day.ToString(), cas.Hours.ToString(), cas.Minutes.ToString(), textBox1.Text);
OleDbConnection povezava = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\users1.mdb");
povezava.Open();
OleDbCommand cmd = new OleDbCommand(strSQL, povezava);
cmd.ExecuteNonQuery();
MessageBox.Show("Uspesno potrjene ure!");
povezava.Close();
- login.uporabnik is a string from another form.
- as you can see ive tried without {} and the result is the same
- is there a problem with sql code? tried with diffrent space positions and stuff?
Anyway... i just want to add some data in almost all the columns. Im a newbie with working with DB in C# so i turn to you - the experts.
Thanks for your answers infront.
Matjaž
Força Barça!
|
|
|
|
|
You insert command will break if any of the values you are inserting contains ' (or any other character that needs to be escaped). It is always better to use parametrized queries instead of string concentration because:
1. You will prevent program from sql injection attacks. SQL Injection Attacks and Some Tips on How to Prevent Them[^]
2. You will avoid issues with special characters that need escaping.
3. Performance will increase.
And the code will be easier to read and understand.
|
|
|
|
|
Hi Giorgi,
His connection string is @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\users1.mdb" , this @ symbol points his Data Source to C:\\users1.mdb , can this causes any exception? Because the correct path is C:\users1.mdb
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
I am not sure about that as he has no problem opening connection. But he does have problems with update statement.
|
|
|
|
|
I made an application right now:
string cs = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\s.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
SqlConnection conn = new SqlConnection(cs);
conn.Open();
conn.Close();
It worked correctly but I have error if I change the AttachDBFilename to C:\\s.mdf .
I don't know if this is his problem or not but I think he should change his path to C:\users1.mdb
When you're alone in the Dark, Fear will protect you...
|
|
|
|
|
Giorgi said right. I have no problems opening the DB. If u have @ infornt of the path or not - makes no difference (at least to me).
Well i still havent fixed my problem. Thanks Giorgi for your link... will check it but currently, i dont need no security percautions as the user will be only me and the data entered wouldnt effect that much on anything (even if brackets would be entered which i doubt they'll be).
Im not worried about the injections. That will be fixed when the first insert into statement would work
I just need some help inserting new data into my database. If possible, my code edited and working as im stuck where i left it (you have a copy on the first post).
Thanks,
Matjaž
Força Barça!
|
|
|
|
|
Ok i just figured it would with a bit of help of google.
Found an example of reading and some problems with it. The solution was to add the brackets [] on the column names
Now everything works.
I'd like to thank you all for viewing my problem and trying to help.
Bye,
Matjaž
Força Barça!
|
|
|
|
|
Hi
I need 1 ms accurate timer in my C# application. I have tried to do this with C# system timer:
timer1.Interval = 1;
timer1.Enabled = true;
but it is not 1 ms accurate.
How should I solve this problem?
Thnx
|
|
|
|
|
sasabunetic wrote: How should I solve this problem?
You will have to use the native multimedia timer. Look on PInvoke.net or Google how to use that.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks for this.
You've helped me alot
|
|
|
|
|
|
None of them have a resolution of less than 10-15 milliseconds.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks, I didn't know it
|
|
|
|
|
AFAIK, DateTime.Now.Ticks has 100ns intervals. You may give it a try...
Regards,
Always keep the Murphy Rules in mind!
|
|
|
|
|
Not an answer.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
http://cplus.about.com/od/howtodothingsinc/a/timing.htm
Stopwatch st=new Stopwatch();
st.Start();
Console.WriteLine("Started");
for (ulong i2 = 0; i2 < 10000000; i2++)
{
ulong ul2 = i2;
ul2++;
}
st.Stop();
Console.WriteLine("Elapsed = {0}", st.Elapsed.ToString());
if (Stopwatch.IsHighResolution)
Console.WriteLine("Timed with Hi res");
else
Console.WriteLine("Not Timed with Hi res");
Enjoy
|
|
|
|
|
Not what the OP asked. He wants a timer, not timing.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|