本帖最后由 胡振超 于 2012-3-31 21:17 编辑
using (SqlConnection conn = new SqlConnection(constr))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
com.CommandText = "SELECT locname FROM callerloc WHERE (startnum <= @num) AND (@num <= endnum) GROUP BY locname";
com.Parameters.Add(new SqlParameter("num",txtNumber.Text.Trim()));
string locname = Convert.ToString(cmd.ExecuteScalar());
MessageBox.Show(string.Format("您查询的号码归属为:{0}", locname), "消息", MessageBoxButtons.OK);
}
} |