|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating a search function in vb.netI 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 Daniel <Dan***@discussions.microsoft.com>'s wild thoughts
were released on Mon, 26 Feb 2007 03:24:03 -0800 bearing the following fruit: >Dear All Groups for VB2003 and VB2005 have 'dotnet' in the name.> >I need some help. This group is for VB6 (and below) J Show quoteHide quote >I've got a deadline for this friday and i'm stuck. what Jan Hyde (VB MVP)>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 -- They considered their silver anniversary a sterling event. (Jumble)
Show quote
Hide quote
"Daniel" <Dan***@discussions.microsoft.com> wrote in message <response type="generic" language="VB.Net">news:E17441B8-8BEE-41FE-8709-96D206649F3B@microsoft.com... > 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 . > > <snipped> This newsgroup is for users of Visual Basic version 6.0 and earlier and not the misleadingly named VB.Net or VB 200x. Solutions, and often even the questions, for one platform will be meaningless in the other. When VB.Net was released Microsoft created new newsgroups devoted to the new platform so that neither group of developers need wade through the clutter of unrelated topics. Look for newsgroups with the words "dotnet", "framework", or "vsnet" in their name. For the news.microsoft.com news server try these: news://msnews.microsoft.com/ microsoft.public.dotnet.languages.vb microsoft.public.dotnet.languages.vb.controls microsoft.public.dotnet.languages.vb.data microsoft.public.dotnet.framework.adonet microsoft.public.dotnet.framework.windowsforms.controls microsoft.public.dotnet.framework.windowsforms.databinding </response>
Sad
Inline Assembly In VB6 Database connection problem on VB6.0 How to open a CMD Line exe as hidden and wat for it to finish Have a problem that is stumping me. VB6 DLL Assembly Compile Link how??? Problem populating a combobox if cases differ Interlocked Functions vs VB Reading Current Value Full Control to Users programmatically Help in translating C to VB |
|||||||||||||||||||||||