HighTechTalks DotNet Forums  

Creating a search function in vb.net

Dotnet Data Tools microsoft.public.dotnet.datatools


Discuss Creating a search function in vb.net in the Dotnet Data Tools forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Daniel
 
Posts: n/a

Default Creating a search function in vb.net - 02-26-2007 , 08:40 AM






Dear All

I need some help. I've got a deadline for this friday and i'm stuck. what
i'm trying to do is have 1 textbox, datagrid and 1 button then when the user
enter a search string, and press the button, I want the result to be
displayed in the datagrid.

At the moment, when the user press the button the system checks if there is
any text in the text box, if there isn’t then it calls the BindDataGrid2()
function which displays everything that’s in the table .

So basically I’m not able to use the value that is in the textbox to make a
custom query.

Please help me

Thank you
Dan

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim mun As String
Dim textBinding As String
Dim Mark As String



' filter = TextBox1.Text

If TextBox1.Text = "" Then
BindDataGrid2()
' DataGrid2.Visible = False
Else



textBinding = TextBox1.Text


Dim strSQL As String = _
"SELECT * FROM ChangeLog where ChangeDetails = 'textBinding'"


With DataGrid2
' Set the DataKeyField so that the DataKeys collection is
filled and
' usable in the ItemCommand event handler. See further
comments in
' grdCustomers_ItemCommand(), above.
.DataKeyField = "ChangeID"
.DataSource = CreateDataSet(strSQL)
.DataBind()
End With
End If



End Sub

' This routine calls CreateDataSet and binds the Customers DataGrid to
the
' return value.

' This routine calls CreateDataSet and binds the Customers DataGrid to
the
' return value.
Sub BindDataGrid2()
Dim textBinding As String
Dim mun As String

textBinding = TextBox1.Text
' textBinding = pete

Dim strSQL As String = _
"SELECT * FROM ChangeLog "
'where ChangeDetails = mun"


With DataGrid2
' Set the DataKeyField so that the DataKeys collection is filled
and
' usable in the ItemCommand event handler. See further comments
in
' grdCustomers_ItemCommand(), above.
.DataKeyField = "ChangeID"
.DataSource = CreateDataSet(strSQL)
.DataBind()
End With
End Sub



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.