Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Column Not Found
Message
 
 
À
05/12/2014 02:27:11
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
ASP.NET
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01611884
Message ID:
01611901
Vues:
40
>At learning Stage I have a problem in following code;
>
>SqlDataSource2.FilterExpression = "fld1 = " + TextBox1.Text; is giving column not error
>
>
>public partial class OffPage : System.Web.UI.Page
>{
>    SqlConnection con3 = new SqlConnection(ConfigurationManager.ConnectionStrings["LoginCS"].ConnectionString);
>    SqlCommand cmd3 = new SqlCommand();
>
>    protected void Page_Load(object sender, EventArgs e)
>    {
>       con3.Open();
>    }
>    protected void Button1_Click(object sender, EventArgs e)
>    {
>        if (Convert.ToInt32(RadioButtonList1.SelectedValue) == 0)
>        {
>            TextBox1.Text = "Pending";
>            SqlDataSource2.FilterExpression = "fld1 = " + TextBox1.Text;
>        }
>        if (Convert.ToInt32(RadioButtonList1.SelectedValue) == 1)
>        {
>            TextBox1.Text = "FWD";
>            SqlDataSource2.FilterExpression = "fld1 = " + TextBox1.Text;
>        }
>        
>    }
> }
>
Your problem is in not using the parameters. I also don't understand why do you mix SqlDataSource and SqlCommand. If you're using SqlCommand, look into SqlParameter, declare parameters for each of your expressions.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform