این قسمت برای دکمه جستجو نوشته شده.....:
protected void Button5_Click(object sender, EventArgs e)
{
Label1.Text = "";
string mak = textBx_Search.Text;
string str_conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/SHIRAZ.mdb";
string str_query = " select Text from table1 where name='" + mak + "'";
OleDbDataAdapter da = new OleDbDataAdapter(str_query, str_conn);
DataSet ds = new DataSet();
try
{
da.Fill(ds, "Table");
Label1.Text = ds.Tables["Table"].Rows[0].ItemArray[0].ToString();
}
catch (OleDbException X)
{
Label1.Text = "اشکال در برقراری ارتباط با پايگاه داده";
}
catch (Exception x)
{
Label1.Text = "لطفا در وارد کردن نام دقت فرمایید";
}
}
اینم کد واسه خود صفحه و اتصال....
<p class="style3" dir="rtl" style="direction: rtl; unicode-bidi: embed;">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="name" DataSourceID="SqlDataSource1"
ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#E3EAEB" />
<Columns>
<asp:BoundField DataField="name" HeaderText="نام مکان ديدنی" ReadOnly="True"
SortExpression="name" />
<asp:BoundField DataField="Text" HeaderText="آدرس" SortExpression="Text" />
</Columns>
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SHIRAZConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:SHIRAZConnectionString2.Provider Name %>"
SelectCommand="SELECT * FROM [Table1]"></asp:SqlDataSource>
</p>