在Script中读取数据库的方法如下,请参考:
- public void ActiveReport_ReportStart()
- {
-
- string str = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=USER.MDB;Persist Security Info=False";
- string sql = "select * from Customers";
- System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(str);
- conn.Open();
- System.Data.DataSet ds = new System.Data.DataSet();
- System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sql, conn);
- da.Fill(ds, "Customer");
- TextBox名字.Text = ds.Tables["Customer"].Rows[0]["名字"].ToString();
- TextBox住所.Text = ds.Tables["Customer"].Rows[0]["住所"].ToString();
- TextBox公司.Text = ds.Tables["Customer"].Rows[0]["公司"].ToString();
- TextBox图片.Text = ds.Tables["Customer"].Rows[0]["图片"].ToString();
-
- }
复制代码 |