Sub veriGetir(ByVal obj As Object, ByVal e As EventArgs)

Dim DBConnection As OleDbConnection

Dim DBCommand As OleDbCommand

Dim dbreader As OleDbDataReader

Dim SQLString As String

Dim baglantiMetni As String = "provider=Microsoft.jet.OLEDB.4.0;data source=" & Server.MapPath("dbguestbook.mdb")

Try

DBConnection = New OleDbConnection(baglantiMetni)

DBConnection.Open()

SQLString = "select * from tablo where kimlik = " + degKim.Text

DBCommand = New OleDbCommand(SQLString, DBConnection)

dbreader = DBCommand.ExecuteReader

dbreader.Read()

degAd.Text = dbreader(1).ToString

degTel.Text = dbreader(2).ToString

dbreader.Close()

DBConnection.Close()

Catch ex As Exception

Response.Write(" <font color=green class=’hata’>" + ex.Message + "</font><br>")

End Try

End Sub

Sub guncelle(ByVal obj As Object, ByVal e As EventArgs)

Dim DBConnection As OleDbConnection

Dim DBCommand As OleDbCommand

Dim SQLString As String

Dim baglantiMetni As String = "provider=Microsoft.jet.OLEDB.4.0;data source=" & Server.MapPath("dbguestbook.mdb")

If passw.Text = "PAROLANIZ" Then

Try

DBConnection = New OleDbConnection(baglantiMetni)

DBConnection.Open()

SQLString = "update tablo set ad=’" + degAd.Text + "’ ,tel=’" + degTel.Text + "’ where kimlik=" + degKim.Text

DBCommand = New OleDbCommand(SQLString, DBConnection)

If (DBCommand.ExecuteNonQuery() > 0) Then

Response.Write("<font color=blue>Islem Tamam, sayfay tazeleyiniz.</font>")

Else

Response.Write("<font color=red>Olmadi!</font>" + SQLString)

End If

DBConnection.Close()

Catch ex As Exception

Response.Write(" <font color=green class=’hata’>" + ex.Message + "</font><br>")

End Try

Else

Response.Write("<font color=red class=’hata’>Parola girilmesi gereklidir veya parola hataldr.</font>")

End If

End Sub

</script>

<style type="text/css">

<!

.parola

{

color: #F00;

}

body

,td,th {

font-family: Trebuchet MS, Arial, Helvetica, sans-serif;

color: #600;

}

body

{

background-color: #CF9;

}

.hata

{

color: #FF0000;

background-color: #FFFFCC;

padding: 1px;

margin: 2px;

display: block;

}

–>

</style>

</head>

<body>

<h1>Tarik’s ASP.NET Demo Page – ASP.NET 1.1</h1>

<form id="Form1" runat="server">

<h2>Veri Listeleme (tablo)</h2>

<asp:datagrid ID="datagrid1" runat="server" BackColor="White"

BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="4"

ForeColor="Black" GridLines="Vertical" AllowPaging="True"

AllowSorting="True" ShowFooter="True" style="text-align: center">

<FooterStyle BackColor="#CCCC99" />

<SelectedItemStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />

<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right"

Mode="NumericPages" />

<AlternatingItemStyle BackColor="White" />

<ItemStyle BackColor="#F7F7DE" />

<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />

</asp:DataGrid>

<h2>Veri Arama (ad icinde parcali)</h2>

<p><asp:TextBox ID="arama" Text="" runat="server" MaxLength="15"/>

&nbsp;<asp:Button id="aramak" runat="server" Text="Arama (search)"/>&nbsp;Bo

arama ile tm kaytlar getirilebilir.

</p>

<h2>Veri Ekleme</h2>

<p>Ad:<asp:TextBox ID="ad" Text="" runat="server" MaxLength="15"/><br/>

Tel:

<asp:TextBox ID="tel" Text="" runat="server" MaxLength="15"/></p>

<p>

<asp:Button id="ekleme" runat="server" Text="Kayit Ekle (insert)" OnClick="ekle"/>

</p>

<h2>Veri Guncelleme</h2>

<p>

Deitirilecek Kimlik No:

<asp:TextBox ID="degKim" Text="" runat="server" MaxLength="15"/> <asp:Button id="veriGetirir" runat="server" Text="Getir" OnClick="veriGetir"/> <br/>

Ad:

<asp:TextBox ID="degAd" Text="" runat="server" MaxLength="15"/><br/>

Tel:

<asp:TextBox ID="degTel" Text="" runat="server" MaxLength="15"/></p>

<p>

<asp:Button id="Button1" runat="server" Text="Kayit Guncelle (update)" OnClick="guncelle"/>

</p>

<h2>

Veri Silme

</h2>

<p>Silinecek Kayt Kimlik No:

<asp:TextBox ID="kimlik" Text="" runat="server" MaxLength="15"/>

&nbsp;<asp:Button id="silme" runat="server" Text="Kayit Sil (delete)" OnClick="sil"/> </p>

<hr>

<p><span class="parola">Kayt eklemek/silmek iin parola giriniz:

<asp:TextBox id="passw" TextMode="Password" runat="server" MaxLength="15" />

</span></p>

</form>

</body>

</html>