Re: DataTable.select problem with variables
- From: Manikandan <plmanikandan@xxxxxxxxx>
- Date: 1 May 2007 03:50:13 -0700
On May 1, 11:29 am, "Jon Skeet [C# MVP]" <s...@xxxxxxxxx> wrote:
On May 1, 11:24 am, Manikandan <plmanikan...@xxxxxxxxx> wrote:
<snip>
I would like to know,as I'm missing quotes or syntax mistake for
variable in select statement.
Your code is trying to find rows with s1=1 and s2=2. There are no rows
matching that query, because for each of your test rows, s1=s2.
Jon
Hi,
Sorry i mistakenly used
string v2="2";
It's also "1"
only
i.e string v2="1";
DataTable aDataTable = new DataTable();
aDataTable.Columns.Add("s1", typeof(string));
aDataTable.Columns.Add("s2", typeof(string));
aDataTable.Columns.Add("s3", typeof(string));
aDataTable.Columns.Add("s4", typeof(string));
for(int i=0;i<10;i++)
{
DataRow dr = aDataTable.NewRow();
dr["s1"]=i.ToString();
dr["s2"]=i.ToString();
dr["s3"]=i.ToString();
dr["s4"]=i.ToString();
aDataTable.Rows.Add(dr);
}
string v1="1";
string v2="1";
string qry="s1= '" + v1 + "' AND s2='" + v2 +
"'" ;
DataRow[] foundRows=aDataTable.Select(qry);
if(foundRows.Length>0)
{
// process here
}
I'm actually taking the values from database(sql server) and using in
select statement.
For demonstration only i used above code, is there any chance of
problem from sql server 2000
Thank You,
Regards,
Mani
.
- Follow-Ups:
- Re: DataTable.select problem with variables
- From: Jon Skeet [C# MVP]
- Re: DataTable.select problem with variables
- References:
- DataTable.select problem with variables
- From: Manikandan
- Re: DataTable.select problem with variables
- From: Jon Skeet [C# MVP]
- DataTable.select problem with variables
- Prev by Date: Re: Regex internal caching or what?
- Next by Date: What is the format of .imd file
- Previous by thread: Re: DataTable.select problem with variables
- Next by thread: Re: DataTable.select problem with variables
- Index(es):
Relevant Pages
|