不好意思 請問一下
我去抓SQL內的資料出來比對
但是我抓出來卻不會比對 只會把全部抓出來(意思就是說 我隨便打一個東西 他就會把所有資料庫內的值秀出來)
不知道是哪邊的問題??(我抓資料的方法不夠好??)
還有 除了資料庫內全部會秀出來之外
在最後一筆資料下面還有個將近15個左右的空白
是要改jquery??
autocomplete.aspx.cs private string Conn = ConfigurationManager.AppSettings["ConnectionString"];
protected void Page_Load(object sender, EventArgs e)
{
getData1();
}
private void getData1()
{
string q = Request["q"];
if (q == "")
{
return;
}
else
{
SqlCommand oCmd = new SqlCommand();
oCmd.Connection = new SqlConnection(Conn);
oCmd.CommandText = @"select case_name from shtc_case group by case_name";
oCmd.CommandType = CommandType.Text;
SqlDataAdapter oda = new SqlDataAdapter(oCmd);
DataSet ds = new DataSet();
oda.Fill(ds);
string[] data = new string[ds.Tables[0].Rows.Count];
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
string ss = ds.Tables[0].Rows[j]["case_name"].ToString();
data[j] = ss.ToString();
}
foreach (string x in data)
{
Response.Write(x+"\n");
}
//string[] data = new string[] { "trhtrhr", "acvbcv", "cbvxbdfb", "adqfvbb", "otulyjfgsdg" };
}
}
} |