how to edit and update my access db using datagrid

liunx

Guest
well i created a aspx page that displays content of two tables . Now i want add and edit and delete buttons to same page so that it allow me edit and update the content access db using datagrid and text box in new page. But i do not know how i can do that. i be happy if some one help me . I mean once i click on edit button it goes to a new page and displays the same record in edit boxes and allow me to change and submit it again.Thanks

here is the code i created:

<%@ Page enableViewState="False" Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>



<script language="vb" runat="server">

Sub Page_Load(Sender As Object, E as EventArgs)
Dim objConnection As OleDbConnection
Dim objCommand As OleDbDataAdapter
Dim strConnect As String
Dim strCommand As String
Dim DataSet1 As New DataSet

strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;"
strConnect += "Data Source=C:\Inetpub\wwwroot\"
strConnect += "db\"
strConnect += "\TENNIS DATABASE.mdb;"
strConnect += "Persist Security Info=False"

Response.Write("Viewing Player Record No:" +Request.QueryString("person_id")+"")


strCommand = "SELECT * FROM players where playerno = " +Request.QueryString("person_id")+";"
objConnection = New OleDbConnection(strConnect)
objCommand = New OleDbDataAdapter(strCommand, objConnection)
objCommand.Fill(DataSet1, "players")
DataGrid1.DataSource=DataSet1.Tables("players").DefaultView
DataGrid1.DataBind()

'second select


Dim strCommand2 As String
Dim DataSet2 As New DataSet

strCommand2 = "SELECT * FROM PENALTIES where playerno = " +Request.QueryString("person_id")+";"
objConnection = New OleDbConnection(strConnect)
objCommand = New OleDbDataAdapter(strCommand2, objConnection)
objCommand.Fill(DataSet2, "PENALTIES")
DataGrid2.DataSource=DataSet2.Tables("PENALTIES").DefaultView
DataGrid2.DataBind()
end sub
</script>


<html>
<head>
<title>Data Grid Control example</title>
</head>
<body>
<asp:DataGrid id="DataGrid1" runat="server" />
<br>
<br>

<asp:DataGrid id="DataGrid2" runat="server" />

</body>
</html>
 
Top