第二种方法就是在写代码来绑定:
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()
你sql写的有问题,你换上下面这句试试吧:string
sqlc="update
oa_user
set
mima='"+newpwd+"'
where
[name]='"+usename+"'
and
mima
='"+oldpwd+"'"
如果StudentID是int类型的话,那么sql是:delete from StudentCourse where StudentID="+StudentID+" and CourseName='语文'"注意如果是varchar类型,一定要加单引号,CourseName是varchar吧,所以语文要加单引号
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)