日期:2014-05-18  浏览次数:20462 次

在Access数据库的更新数据行...(Access + DataGrid)
在Access数据库的添加数据行和删除行,都测试成功了。
可是更新数据行就是不行...
查了很多文章,可惜...
还希望那位高手指点...

下面为源码.........

<%@   Page   Language= "VB "   ContentType= "text/html "   ResponseEncoding= "utf-8 "   %>
<%@   Import   Namespace= "System.Data "   %>
<%@   Import   NameSpace= "System.Data.OleDb "   %>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 "   />
<link   media= "all "   rel= "stylesheet "   type= "text/css "   href= "CSS/Style.css "   />
<title> Update </title>
<script   language= "VB "   runat= "server ">

        Dim   MyConnection   As   OleDbConnection

        Sub   Page_Load(ByVal   Sender   As   Object,   ByVal   E   As   EventArgs)

                MyConnection   =   New   OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;DATA   Source= "   &   Server.MapPath( "Database/933c1601697f3642.mdb "))

                If   Not   (IsPostBack)   Then
                        BindGrid()
                End   If
        End   Sub

        Sub   MyDataGrid_Edit(ByVal   Sender   As   Object,   ByVal   E   As   DataGridCommandEventArgs)

                MyDataGrid.EditItemIndex   =   CInt(E.Item.ItemIndex)
                BindGrid()
        End   Sub

        Sub   MyDataGrid_Cancel(Sender   As   Object,   E   As   DataGridCommandEventArgs)

                MyDataGrid.EditItemIndex   =   -1
                BindGrid()
        End   Sub

        Sub   MyDataGrid_Update(ByVal   Sender   As   Object,   ByVal   E   As   DataGridCommandEventArgs)

                Dim   MyCommand   As   OleDbCommand
               
                Dim   UpdateCmd   As   String   =   "UPDATE   RecordBase   SET   RECORD_DATE=@RECORD_DATE,   ADDRESS=@ADDRESS,   ACTION_CODE=@ACTION_CODE,   POLICE_NAME=@POLICE_NAME,   CAR_CODE=@CAR_CODE,   CAR_TYPE=@CAR_TYPE   WHERE   (REC_ID   =   @Id) "