select * from T_number where StartNo<=@No and EndNo>=@No 这样写能查出来吗 字符串能这么比吗
private void select_Click(object sender, EventArgs e)
{
string ConnStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
using (SqlConnection conn = new SqlConnection(ConnStr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "select * from T_number where StartNo<=@No and EndNo>=@No";
cmd.Parameters.Add(new SqlParameter("No",txtMobileNo.Text.ToString()));
using (SqlDataReader sdr = cmd.ExecuteReader())
{
try
{
string 运营商名字 = sdr.GetString(sdr.GetOrdinal("Name"));
MessageBox.Show(运营商名字);
}
catch
{
MessageBox.Show("查询失败,没有找到此条记录");
}
}
}
}
}
我写的代码 有问题吗 |