在我的搜索功能,我需要传递两个参数到SP。在这里我保持条件,但没有得到所需的输出。这里是我的code.any一个帮我如何检查,如果条件它是字符串或不
if (IsValid)
{
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection(myStr);
SqlCommand cmd = new SqlCommand("spRedemItem", con);
cmd.CommandType = CommandType.StoredProcedure;
if(Parameter.Equals(DropDownList2.SelectedValue=="CustomerCode"))
{
cmd.Parameters.AddWithValue("@CustomerCode", txtkey2.Text);
}
else
{
cmd.Parameters.AddWithValue("@CustomerName", txtkey2.Text);
}
SqlDataAdapter sda = new SqlDataAdapter(cmd);
Session["CustomerName"] = dt;
con.Open();
DataSet ds = new DataSet();
sda.Fill(ds);
dt = ds.Tables[0];
Label10.Text = dt.Rows[0]["ItemCode"].ToString();
Label11.Text = dt.Rows[0]["CustomerName"].ToString();
Label12.Text = dt.Rows[0]["PointsNeeded"].ToString();
// Session["CustomerName"] = dt;
View.DataBind();
con.Close();
}
的[我如何在Java中比较字符串?]可能重复(http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java) –