第二种方法就是在写代码来绑定:
OleDbConnection conn = new OleDbConnection()
//conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=E:/Microsoft_Visual_Csharp.net/练习簿/笔记/user.mdb"
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=E:\\Microsoft_Visual_Csharp.net\\练习簿\\笔记\\user.mdb"
//上面两个connectionstring都行,它们只是那个分格符不同,你仔细看一下就发觉了。
OleDbCommand comm = new OleDbCommand("SELECT * FROM [user]", conn)
OleDbDataAdapter da = new OleDbDataAdapter()
da.SelectCommand = comm
DataSet ds=new DataSet()
da.Fill(ds)
GridView2.DataSource = ds.Tables[0].DefaultView
GridView2.DataBind()
conn.open "driver={microsoft access driver (*.mdb)}dbq="&server.mappath("xhnew.mdb")修改为:
conn.open "DBQ=d:\newexcel.xlsDefaultDir=DRIVER={Microsoft Excel Driver (*.xls)}"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)