DataList error

  • Thread starter Thread starter Dharmen
  • Start date Start date
D

Dharmen

Hey Guys,
I know some of u guys tried to help me but it didnt work....
I have a SQL Database from which im trying to display some data!
I'm using this SqlCommand:
SqlCommand sqlCmd2 =new SqlCommand("SELECT x FROM ytable WHERE
z="+this.ddList1.SelectedItem.Text.ToString(),conn);

It reads the selected item properly but gimes me an eror saying, Invalid
coulmn name "xyz";

xyz is one of the values for z which was selected from
this.ddList1.SelectedItem.Text.ToString();

Please help me thanks!
 
Hi,

You should quote the string value (note single quotes):
....
z='"+this.ddList1.SelectedItem.Text.ToString() + "'",conn);
 
Please add single quotes to the value
SqlCommand sqlCmd2 =new SqlCommand("SELECT x FROM ytable WHER
z='"+this.ddList1.SelectedItem.Text.ToString() + "'",conn)

Bin Song, MC
 
Hey Guys,
Thanks that worked!
But now it says unable to load when no data is available :( can i have any
one of ur MSN ID please?
Thanks
 
Back
Top