|
did you try
<br />
col1 = dr["col1"].ToString().Trim();<br />
col2 = dr["col2"].ToString().Trim();<br />
col3 = dr["col3"].ToString().Trim();<br />
<br />
if( dr["col4"] == DBNull.Value )<br />
{<br />
recordsSelected = dt.Select("col2 = " + "'" + col2 + "'" + " And col1 = " + "'" + col1 + "'" + " And col3 = " + "'" + col3+ "'" + " And col4 = ''"); <br />
}<br />
else<br />
{<br />
col4 = dr ["col4"].ToString().Trim(); <br />
recordsSelected = dt.Select("col2 = " + "'" + col2 + "'" + " And col1 = " + "'" + col1 + "'" + " col3 = " + "'" + col3 + "'" + " And col4 = " + "'" + col4 + "'");<br />
}<br />
|
|
|
|
|
I already tried that. If you read my post I have that select line already in my code. I want to find out a work around. I replaced all nulls to the empty strings. However, this approach may not work if a column i am looking for is not string. As a result, if someone knows a better way or other way to select if values are null in datatable.
Thanks
Needy
|
|
|
|
|
bemahesh wrote: I already tried that. If you read my post I have that select line already in my code. I want to find out a work around. I replaced all nulls to the empty strings. However, this approach may not work if a column i am looking for is not string. As a result, if someone knows a better way or other way to select if values are null in datatable.
I can't image that a real null value in the column, and comparing that to DBNull.Value would take longer than doing the string comparision you are doing now. What you are doing sounds like bad design work. I think you need to go back, and set all those columns to null, and compare them to DBNull.Value .
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
If I was not clear enough, the problem is when i am trying to select the data from datatable using datatable.select(). If i have null value in one of the column in datatable and i am selecting from the datatable like: datatable.select("col4 is null").
That is where it takes longer time.
Please, look at my original post
this line is not creating overhead: if (col4 == "") // if column4 is null then use this
But, this line does:
dt.Select("col2 = " + "'" + col2 + "'" + " And col1 = " + "'" + col1 + "'" + " And col3 = " + "'" + col3+ "'" + " And col4 is null");
Thanks
Needy
|
|
|
|
|
I converted a project from Java to C# using Java Language Conversion Assistant 3.0:
Please take a look at the conversions and let me know what changes I might need to make.
I appreciate your help
***See following 2 samples ***
****example 1 ******
using System;
using System.Xml;
using System.Xml.Serialization;
using System.Data;
using System.Text;
using System.Collections;
namespace JBCT
{
public class Attribute
{
public @XMLSerializable int attributeId = 0;
public XMLSerializable String;
attributeName=null;
public XMLSerializable ArrayList;
< String > attributeValues = new ArrayList < String >();
public Category parentCategory = null;
public Attribute()
{
}
}
}
***** example 2 *********
using System;
using System.Xml;
using System.Xml.Serialization;
namespace TGC
{
public class Product
{
virtual public BitList NewBitList
{
get
{
return new BitList((productVariations == null)?0:productVariations.size());
}
}
public @XMLSerializable int subcatId = 0;
public XMLSerializable String;
displayName = null;
public XMLSerializable String;
brand = null;
public XMLSerializable String;
tagLine1 = null;
public XMLSerializable String;
tagLine2 = null;
public XMLSerializable String;
tagLine3 = null;
public XMLSerializable String;
thumbnailImage = null;
public @ XMLSerializable boolean onSale = false;
public XMLSerializable ArrayList;
< ProductVariation > productVariations = new ArrayList < ProductVariation >();
public XMLSerializable HashMap;
< String, BitList > [] productAttributeValues = null;
public Category parentCategory = null;
public Product()
{
}
public class ProductVariation
{
public @ XMLSerializable int productId = 0;
public @ XMLSerializable int price = - 1;
public ProductVariation()
{
}
}
|
|
|
|
|
The only person who is going to know that is you. Does the app run?? Does it do what you epect it to do?? Only when you have a working version can you go back and rewrite it from scratch to eliminate all the "funk" that the converter added for you.
|
|
|
|
|
|
Having two options with the same name is confusing to clients. How can the client tell which Joe he or she is selecting? If it is by which appears first in the list, then you should prepend everyone's name in the list with the list item number. Having two identical options is a design flaw that needs to be addressed here, not the fact that c# doesn't allow you to implement it (IMO).
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I have started on an astrology program and need to get up to speed with C# graphics and drawing. Some of the things I need to figure out are how to:
1. Draw a chart
2. List aspect images together with the planet images that form a triangle
3. Print all the above aswell
Is there any good book that can help me? Any sources on the internet? Anyone who did a similar program before? Thanks to everyone in advance, who can give me some advice!!!
|
|
|
|
|
Hello All:
Anyone know how can I can change the computer name , I want to design a form, when I press a change button like in (My computer->properties there is a text box and button throw it we can change our computer name) , please any idea....
Thanks all
|
|
|
|
|
If it can be done, I'm sure you wouldn't ask us for help if it were to, say, be answered by the first result when searching google for c# computer name change[^]
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi
Thanks for your answer but I was just ask , these programs like
(IR,bluetooth, etc..), it's allow to the user change the PC name (appearance name) , I want that step , Can I do it or not ??
thanks alot....
|
|
|
|
|
Already answered in my previous post (and by Dave in his post)
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
You might want to not lean on the Enter key when you type your posts...
The only way to change the computer name is to call the Win32 API function SetComputerNameEx[^], or if you just need to change the NetBIOS name, SetComputerName[^]. Changing the computer name requires a restart of the machine for the change to take effect.
|
|
|
|
|
This one is tricky, that's for sure. I'm looking for a way to generate strings based on a regular expression.
I tried several searches on google and the only stuff that turned up was a library called Grail+ and some perl module genex.
Before I'm going to hack my way into integrating perl into my C# application I want to make sure that I haven't missed a library that does what I need.
Is there anyone who has done this before or knows a library which can help me with this?
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|
|
Are you just trying to generate random strings that match the regex? What could this possibly be used for? I doubt such functionality is already in the .Net framework, but I am not certain. You could create your own state machine based on a regex, then getting a random string is done trivially by randomly choosing paths from one state to another until you arrive at one of the success states (unless you want to bound or specify the resulting string's length). Anyway, good luck, and let us know if you find a solution elsewhere.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Indeed, I want to generate random strings that match the regex. I'm generating random data for a database which has some fields that need to match to a specific pattern. I'm pretty sure .NET doesn't have the functionality I'm looking for.
I think creating my own state machine is indeed the best way to go around this, however it's not going to be easy and there is a problem with the max length of strings. I need to find a way to limit the length of the data generated by the * and + operator otherwise this is impossible to do.
Thanks nonetheless
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|
|
Here is how I would implement it, if I were going to do what you describe (where 'n' is the desired length of the result):
1. Build a directed graph of your regex with nodes==state and edges==allowed state transitions
2. Build a structure containing the number of steps that can be made from
any one state to any other that is <= the length of your result (2d matrix of lists)
3. Randomly choose an acceptance state (named 'as') where your connectivity matrix
indicates you can go from the start state to the final state in exactly n transitions.
4. Iterate through the following (initialize cur = startStateNode) until your string is found:
a. Set 'n' to 'n-1'
b. Out of all of the nodes reachable from 'cur' in one move,
eliminate those that can not reach 'as' in 'n' moves
c. Choose one of the resulting nodes in the collection found in (b) Once you finish with this process, you will have a randomly generated string matching your regex. Note, however, that strings produced do NOT have equal probability of being chosen. For example, if your regex is, say "(Becky|a\w*)", then "Becky" will result half of the time, whereas words beginning with the letter "a" (this set is clearly much larger) would take the other half. Choosing one at random with equal probability would require you to find ALL matching strings of your given length first, then choosing one of those strings at random (or, you could use graph theory and weight each choice by the number of possible ways to arrive at the destination in the required number of moves). Whatever you decide, I hope you can see that this is clearly not a trivial computation, and it will require a significant (IMO) source of man-hours to code. Good luck,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thanks for the outline, it got me thinking about how regex parsers are actually build. I found some old material on how to write your own regex parser and I'm going to use that for my library.
My plan is to implement a partial regex parser. This parser will be constructing an NFA of the regex expression and convert it to a DFA.
After that I'm going to determine which parts of the DFA will have a fixed length, those parts will need to be generated first. When these parts are generated I will be filling up the rest of the string with the other variable length parts, starting with the operator + (You need at least one if these) and after that the * operator.
WM.
What about weapons of mass-construction?
"What? Its an Apple MacBook Pro. They are sexy!" - Paul Watson
My blog
|
|
|
|
|
Does anybody have sample project of code for creating simple TaskDialogs in framework 2.0, without any unsafe/unmanaged code?
Thanks.
|
|
|
|
|
If you are referring to the TaskDialog provided by Vista, the only way to do this in .NET is to use interop to the Win32 APIs. There are several examples of how to do that here on CP. There are also some examples that show how to make a TaskDialog-like dialog. Search Results[^]
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
I am trying to read the columns in a selected gridview row. The column value is 760 but when I rund it I get "Blaaaaa". I also tryed doing a while statement before the if statement but that didnt' work either. Below is the code:
public void GridView1_SelectedIndexChanged(Object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
string cmopid = row.Cells[1].Text;
string Packageid = row.Cells[2].Text;
string carrier = row.Cells[3].Text;
if (cmopid == "760")
{
Labeltest.Text = "Good to Go";
}
else
{
Labeltest.Text = "Blaaaaaa";
}
}
|
|
|
|
|
change the following line as indicated:
Labeltest.Text = "Blaaaaaa";
Labeltest.Text = string.Format("{0}; {1}; {2}", cmopid, Packageid, carrier); Then debug by seeing what results you get, and where they are comming from.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
I did that and I got the right values:
xxx;sss;zzz
|
|
|
|
|
So it is working?
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|