又送100分,老问题还没有解决,新问题又来了
rhs 2004-05-03 09:21:13 老问题:http://expert.csdn.net/Expert/topic/3024/3024840.xml?temp=.3193476
但我想把数据查询结果放在一个DataTable中于是把程序写成如下:
this.mTable = new System.Data.DataTable();//这儿有问题??
conn = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OleDb.4.0; Data source = party.mdb");
conn.Open();
string strsql = "select ID,sum(item1+item2...) as total " +
"into tblresult from tblMark "+ "where datediff(mm,date(),dates)=0 group by ID" ;
this.da = new System.Data.OleDb.OleDbDataAdapter(strsql,this.conn);
try
{
this.da.Fill(this.mTable);//发生异常
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"error");
this.conn.Close();
}
异常提示如下:"至少一个参数没有被指定值".哪儿问题啊,是不是mTable的问题??
新问题:
this.DataGrid1 = new DataGrid();
this.tblBook1 = new DataTable();
string mysql = "select tblbooks.bookID,tblbooks.bookName,tblborrow.BorrowDate from tblborrow ,tblbooks "+ "where tblbooks.bookID in (select bookID from tblborrow where Number ='" + Session["id"] +"')";
this.conn = new SqlConnection("server=local;database=lib;uid=sa;pwd=123");
this.da1 = new SqlDataAdapter(mysql,this.conn);
this.da1.Fill(this.tblBook1);
this.labtotal.Text = "你总共借了" + this.tblBook1.Rows.Count.ToString();
Session["moreBook"] = 5 - this.tblBook1.Rows.Count;
this.labMore.Text = "你还可以借" + Session["moreBook"].ToString()+"本";
DataView dv = new DataView(this.tblBook1);
this.DataGrid1.DataSource = dv;
this.DataGrid1.DataBind();
这是一个借书查询的,
第一个问题:查询结果记录重复.同一个记录在结果中连续出现两次.怎样修改sql语句?
第二个问题:tblBook1中有记录显示.但DataGrid1没显示结果,而且连框架都没显示.Visible属性可是true.