<%@ Page Language="VB" Debug="True" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
Sub btnSearch_OnClick(sender as Object, e as EventArgs)
Dim objConnection As SqlConnection
Dim objCommand As SqlCommand
Dim objAdapter As SqlDataAdapter
Dim objDataSet As DataSet
Dim strSearch As String
Dim strSQLQuery As String
'search stringini al
strSearch = txtSearch.Text
'kontrol
If Len(Trim(strSearch)) > 0 Then
' bağlantı
objConnection = New SqlConnection("Data Source=serveradı;" _
& "Initial Catalog=databaseadı;User Id=kullanıcı;Password=şifre;" _
& "Connect Timeout=15;Network Library=dbmssocn;")
' SQL query
strSQLQuery = "SELECT * FROM table " _
& "WHERE fieldLIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "ORDER BY field;"
objCommand = New SqlCommand(strSQLQuery, objConnection)
objAdapter = New SqlDataAdapter(objCommand)
objDataSet = New DataSet()
objAdapter.Fill(objDataSet)
dgPaging.DataSource = objDataSet
dgPaging.DataBind()
objConnection.Close()
Else
txtSearch.Text = "Arama Kelimelerini Giriniz"
End If
End Sub
</script>
<html>
<head>
<title>ASP.NET Database Search</title>
</head>
<body>
<form id="Form1" runat="server">
<p>
<asp:textbox id="txtSearch" runat="server" />
<asp:button id="btnSearch" runat="server"
text = "Search"
onclick = "btnSearch_OnClick"
/>
</p>
<p> </p>
<asp:datagrid id="dgPaging" runat="server"
headerstyle-font-bold="True" gridlines="None">
<HeaderStyle Font-Bold="True"></HeaderStyle>
</asp:datagrid>
</form>
<hr />
</body>
</html>