这是代码,请各位路过的朋友帮忙看看,谢谢!
SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr,myConnection);
DataSet ds=new DataSet();
myCommand.Fill(ds,"myTable");
if(ds.Tables["myTable"]==null)
{
Response.Write("null");
}
else{
Response.Write(ds.Tables["myTable"]);
}
SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr,myConnection);
DataSet ds=new DataSet();
myCommand.Fill(ds,"myTable");
if(ds.Tables["myTable"]==null)
{
Response.Write("null");
}
else{
Response.Write(ds.Tables["myTable"]);
}
然后因为没人回应想改成有分给的,一时间找不着在哪里,看到有个"给分"的字眼(结贴给分),随手一点,谁知给我结贴了,真郁闷!
对于"结贴给分",有点歧义,可以理解成"给分"是中心词,然后结贴是定语.
{
string conStr = "Data Source=localhost;Initial Catalog=books;User Id=sa;Password=11;";
SqlConnection myConnection = new SqlConnection(conStr);
if(sqlStr!="")
{
Response.Write(sqlStr);
//结果是:INSERT INTO book (bkName,bkPrice,bkPages) VALUES ('rytry','4645','64566')
}
else
{
Response.Write("sqlStr null");
}
SqlDataAdapter myCommand = new SqlDataAdapter(sqlStr,myConnection);
DataSet ds=new DataSet();
myCommand.Fill(ds,"myTable");
if(ds.Tables["myTable"]==null)
{
Response.Write("null");
}
else{
Response.Write(ds.Tables["myTable"]);
}
Response.Write(ds.Tables["myTable"]);
//myRepeater.DataSource = ds.Tables["myTable"].DefaultView;
//myRepeater.DataBind();
}
你把sql语句改一下,改成“select * from book”,如果再为空,说明表中没有数据
ds.Tables.Add("myTable");
myCommand.Fill(ds,"myTable");
自己在VS 中点出来看就知道,有说明的哈~~~~~~~~