|
if i use varchar(max) instead of varchar(50), and use "chandra" only , then will both give the same performance.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Mogaambo wrote: then will both give the same performance.
Same performance of what? Actually what is this doing in the C# forum? It should be in SQL...
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
i am creating tables on runtime, after reading from a text file but i don't know the datatype size, so if i use varchar(max) will that okay.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Again, please use the SQL forum, NOT C#!!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
It won't make any significant difference to the performance of your C# code.
|
|
|
|
|
Hi,
I made a custom control inherited from 'Button' control.
I made a custom event 'Action' in this userControl I made a access specifier 'public'.
like this :
public delegate void ActionEventHandler(object sender,ActionEventArgs e);
public event ActionEventHandler Action;
protected void OnAction( object sender, ActionEventArgs e)
{
if ( Action != null)
{
Action(sender,e);
}
}
but when I drop this control to a form it doesn't show 'Action' event
in property window.
plz help how to do this...
|
|
|
|
|
|
Ok, i am still having some trouble with the code. I have a controller on the other side with a thermometer and keyboard etc.
I am sending the temperature from there to my form. It normally works fine.
The only time it gives me an error is when the first thing i do (after turning on the controller) is click "show temperature" on my screen form. Then the error that occours is the following:
Invoke or BeginInvoke cannot be called on a control until the window handle has been created.
It also says:
TargetInvocationException was unhandled.
Exception has been thrown by the target of an invocation.
Could it be that the forst time data is in some kind of wrong format? How to make sure that the window handle will be created before BeginInvoke?
Sample code: namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int ledStatus = 0;
int r = 2;
System.IO.Ports.SerialPort sp = new System.IO.Ports.SerialPort();
public Form1()
{
InitializeComponent();
sp.PortName = "COM5";
sp.BaudRate = 19200;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.ReadTimeout = 5000;
sp.Open();
sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
}
void sp_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
this.BeginInvoke(new Action(UpdateData), sp.ReadExisting());
}
public void UpdateData(string character)
{
if (r == 1)
{
string ajutine2 = "0";
ajutine2 += character;
int stringToInt = Convert.ToInt32(ajutine2);
for (int y = 0; y < 1000; y++) ;
if (stringToInt > 100)
progressBar1.Value = stringToInt;
double intToDouble = Convert.ToDouble(stringToInt);
double ajutine3 = intToDouble / 10;
string doubleToString = Convert.ToString(ajutine3);
ekraan1.Text = "";
ekraan1.Text += "Temp: ";
ekraan1.Text += doubleToString;
ekraan1.Text += " *C";
}
else if (r == 2)
{
for (int y = 0; y == 5000; y++) ;
ekraan1.Text += character;
}
}
... }
|
|
|
|
|
introuble2 wrote: It also says:
TargetInvocationException was unhandled.
Exception has been thrown by the target of an invocation.
Look at the Inner or base exception causing this on this TargetInvocationException .
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Do you mean this:
public void showTEMP_Click(object sender, EventArgs e)
{
r = 1;
sp.Write("X");
ekraan1.Text = "";
}
The controller reacts to the "X" and starts the temp conversion and send.
|
|
|
|
|
introuble2 wrote: Do you mean this:
No I dont mean any of that. I never even mentioned anything you wrote! How did you get that?
I mean do:
try
{
}
catch (TargetInvocationException ex)
{
Exception realex = ex.GetBaseException();
}
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I am just beginning with C# and its a tad confusing at the moment.
Anyways, i tried what you said and now it just wont run. It doesnt even print any errors.
However, if i select "start without debugging" i get some information:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.FormatException: Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
at WindowsFormsApplication1.Form1.UpdateData(String character) in C:\Users\raigo\Desktop\Kit Programmid\VISUAL\KIT\KIT\Form1.cs:line 62
Any ideas?
Thanks for any ideas
|
|
|
|
|
introuble2 wrote: Any ideas?
introuble2 wrote: Form1.cs:line 62
Look there. Specifically at what is being passed when calling int.Parse() .
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hi,
I think the problem is that your are opening your serial port before the form has been created.
Move the following code into the forms Load event handler and I think you'll be ok.
sp = new System.IO.Ports.SerialPort();
sp.PortName = "COM5";
sp.BaudRate = 19200;
sp.Parity = Parity.None;
sp.DataBits = 8;
sp.StopBits = StopBits.One;
sp.ReadTimeout = 5000;
sp.Open();
sp.DataReceived += new SerialDataReceivedEventHandler(sp_DataReceived);
Alan.
|
|
|
|
|
I dont think i have a forms load event handler. Should i move the sp.init inside the InitializeComponent method?
|
|
|
|
|
Double click on the form and you will have a Form Load event Or maybe I am misunderstanding what you are asking.
|
|
|
|
|
Thx, but it did not help, the error remains the same. Could it be something with the incorrect format of data on first send?
|
|
|
|
|
I don't know what is causing your error of course, but if you are unsure that what you are getting in the first receive is valid why not look at it and see? Or something as simple as using .TryParse() to let you know if what you are getting can be easily converted to the int32 you are looking for.
|
|
|
|
|
Hi there!
I am currently developing a small database frontend for private use. Obviously I want to search the various collections of business objects I pull out of the database. The search term is entered by the user and should allow for dos-stlyed wildcards (*, ?, #). In the old VB days there was this nice "like" operator (don't flame on me, please!) but since I moved on to c# there is no such thing.
I realize that Regular Expressions are the way to go, but I am unshure on how to implement these old wildcards. Pure RegEx are not an option since I find these to be much to complex for the casual user.
My current solution involves simple find & replace to transform a wildcard-expression into a valid RegEx:
<br />
criteria = criteria.Replace("?", @"\w(1)");<br />
criteria = criteria.Replace("#", @"\d(1)");<br />
criteria = criteria.Replace("*", @".*");<br />
<br />
string regex;<br />
RegexOptions options = RegexOptions.Singleline;<br />
<br />
if (IgnoreCase)<br />
options = options | RegexOptions.IgnoreCase;<br />
<br />
if (WholeWortsOnly)<br />
{<br />
regex = string.Format(System.Globalization.CultureInfo.InvariantCulture, @"(^{0}$|^{0}\s+|\s+{0}$|\s+{0}\s+)", criteria);<br />
}<br />
else<br />
{<br />
regex = criteria;<br />
}<br />
<br />
if (criteria.Length == 0)<br />
{<br />
regex = @"^.{0}$";<br />
}<br />
<br />
RegEx matchRegex = new Regex(regex, options);<br />
<br />
Obviously there are quite some possibilities for the user to bust this code: entering characters with RegEx-specific meaning (^, \, $ ...) will lead to exceptions or unexpected behaviour.
My question is: how do you tackle such thing?
best regards
Arne
|
|
|
|
|
ArneKruger wrote: My question is: how do you tackle such thing?
Regex.Escape()
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 alpha 4a out now (29 May 2008) ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Thanks!
I think I finally got the thing working. The problem with RegEx.Escape was that the dos-style wildcards (*, ?, #) were also escaped by the RegEx.Escape(..) method. I had to perform some preparsing.
|
|
|
|
|
I have always used the Tag property eg when loading a listview I put the row ID into the tag property and use it to locate the row in a table when any processing is done. The same with the treeview, stick the ID into the nodes tag property.
Recently I have seen samples where the object is put into the tag property eg. the datarow instead of the ID value. Certainly makes management easier, I no longer have to go looking for the datarow.
Question is, are there any drawbacks to using the Tag property in this way.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't think so. I always used to keep custom class objects in the tag property and worked well so far. Only problem I felt is casting. Each time you have to cast it back from object.
|
|
|
|
|
Casting has still got to be easier than hunting down a record in a dataview ot table.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Mycroft Holmes wrote: Question is, are there any drawbacks to using the Tag property in this way.
Yup. Memory consumption. You have a play off here between convenience for the developer and possibly a slowdown of the system due to you having to retrieve data based on the tag. The more data you have stored, the greater the memory consumption.
|
|
|
|