ASP.NET数据库查询问题

stringstr="";stringstr1="";stringStationName=this.TextBox2.Text;stringsqlconn=@"Serve... string str = "";
string str1 = "";
string StationName = this.TextBox2.Text;
string sqlconn = @"Server = .;DataBase = Bus; Integrated Security = SSPI;";
SqlConnection myConnection = new SqlConnection(sqlconn);

SqlCommand myCommand = new SqlCommand("select * from RouteTable where Station='" + StationName + "'", myConnection);
SqlDataAdapter Adapter = new SqlDataAdapter();
SqlCommandBuilder cmdB = new SqlCommandBuilder(Adapter);
Adapter.SelectCommand = myCommand;
DataSet myDs = new DataSet();
Adapter.Fill(myDs);
str += "<font size=4><strong>经过" + StationName + "车次如下:</strong></font><br>";
for (int i = 0; i < myDs.Tables[0].Rows.Count; i++)
{
if (myDs.Tables[0].Rows[i][1].ToString() == this.TextBox2.Text.Trim())
{
str1 += "<font color=red>" + myDs.Tables[0].Rows[i][i].ToString() + "</font>路<br>";
}
}
this.Label23.Text = str;
this.Label2.Text = str1;
要查找出符合输入站名的所有线路,但是目前只能查到:

经过朝阳广场车次如下:

14路
朝阳广场路
展开
 我来答
CincyBella
2013-06-26 · 超过13用户采纳过TA的回答
知道答主
回答量:52
采纳率:0%
帮助的人:22.9万
展开全部
You already have two rows returned. that means your code is correct.
Probably, you should check the table to see if you still got 2 records using
"select route, station from routetable where station=@stationname " (like %@stationname%)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式