从索引 0 处开始,初始化字符串的格式不符合规范。代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;public partial class cx_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("local");
con.Open();
SqlCommand sql = new SqlCommand("select * from [sbcx] where [sbmc] [desc]");
SqlDataAdapter admain = new SqlDataAdapter(sql);
DataSet ds=new DataSet();
admain.Fill(ds,"table");
GridView1.DataSource = ds.Tables["table"];
GridView1.DataBind();
con.Close();
con.Dispose();
}
}
界面上定义了一个textbox控件一个button。我的意思是当在textbox输入任何设备名称时,点击button就可以查到关于这个设备在数据库里的所有记录。是不是代码有问题?在哪里??
解决方案 »
- AJAX技术实现两级下拉框联动功能,后台取不到值
- 今天下午有个医疗机构来招聘
- asp.net 如何检测客戶端是否安裝WindowsInstaller-KB893803-v2-x86.exe這個補丁
- 继续求解SQL
- 如何取一个字符串的前几位的字符.....
- *************请问为什么JS改变iframe的frameborder不能生效呢?***************
- 如何在一个htmlTable控件中加入<thead>和<tbody>标记?(加分40)
- asp.net和access修改个人信息,修改不了!?
- 求助关于获取手机客户mac地址的问题
- 为何ASP文件可以运行,而改名ASPX后反而里面的<% %>中的语句不能运行
- 如何设置新闻格式
- vs.net2005调用owc11的问题
SqlCommand sql = new SqlCommand("select * from [sbcx] order by [sbmc] desc");
SQL语句有问题
SqlCommand sql = new SqlCommand(strsql);
传入参数才可以查相关的数据啊
con.Open();
string strsql = "select * from [sbcx] where [sbmc]='"+控件id.text.trim()+"' order by [sbmc] [desc]";
SqlDataAdapter admain = new SqlDataAdapter(sql);
DataSet ds=new DataSet();
admain.Fill(ds,"table");
GridView1.DataSource = ds.Tables["table"];
GridView1.DataBind();
con.Close();
con.Dispose();
//再试试