用Visual C#中轻松浏览数据库记录(2)
iV>.上一条记录和操作后运行界面:
if ( myBind.Position == 0 )
MessageBox.Show ( "已经到了第一条记录!" ) ;
else
myBind.Position -= 1 ;
四.程序源代码:
using System ;
using System.Drawing ;
using System.ComponentModel ;
using System.Windows.Forms ;
using System.Data.OleDb ;
using System.Data ;
public class DataView : Form {
private System.ComponentModel.Container components ;
private Button lastrec ;
private Button nextrec ;
private Button previousrec ;
private Button firstrec ;
private TextBox t_books ;
private TextBox t_bookprice ;
private TextBox t_bookauthor ;
private TextBox t_booktitle ;
private TextBox t_bookid ;
private Label l_books ;
private Label l_bookprice ;
private Label l_bookauthor ;
private Label l_booktitle ;
private Label l_bookid ;
private Label label1 ;
private System.Data.DataSet myDataSet ;
private BindingManagerBase myBind ;
public DataView ( )
{
//连接到一个数据库
GetConnected ( ) ;
// 对窗体中所需要的内容进行初始化
InitializeComponent ( );
}
public override void Dispose ( ) {
base.Dispose ( ) ;
components.Dispose ( ) ;
}
public static void Main ( ) {
Application.Run ( new DataView ( ) ) ;
}
public void GetConnected ( )
{
try{
//创建一个 OleDbConnection
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = sample.mdb" ;
OleDbConnection myConn = new OleDb
相关新闻>>
- 发表评论
-
- 最新评论 更多>>