473,499 Members | 1,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get same dataset while using multiple search control criteria

I have developed a form that would allow the user to load and search a
database several ways, by data range using two combo boxes, by specific
number entered in a text box or all database entries. I'm able to use the
combo box selection method multiple times with no problem However, when I try
to type in a specific drawing number in the txtDrawingNum.text field and
click btnLoad I get the
same dataset that I previously had from the combo boxes. Any ideas?

The data bindings are all to text boxes and one checkbox. It is an MS ACCESS
database I am connecting to.

Imports System.Data
Imports System.Data.OleDb

+ Windows Form Designer generated code

Dim dataset1 As New DataSet1
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source = C:\AutoCAD Project\AutoCAD_Files.mdb; User ID=Admin"
Dim Connection1 As OleDbConnection = New OleDbConnection(ConnectionString)
Dim IDbinding As New Binding("Text", dataset1, "AutoCAD_Files.ID")
Dim FileNamebinding As New Binding("Text", dataset1, "AutoCAD_Files.
FILE_NAME")
Dim FileTitlebinding As New Binding("Text", dataset1, "AutoCAD_Files.
FILE_TITLE")
Dim FileDescbinding As New Binding("Text", dataset1, "AutoCAD_Files.
FILE_DESCRIPTION")
Dim RevLetterbinding As New Binding("Text", dataset1, "AutoCAD_Files.
REV_LETTER")
Dim OrigDatebinding As New Binding("Text", dataset1, "AutoCAD_Files.
ORIGINATION_DATE")
Dim DateModifiedbinding As New Binding("Text", dataset1, "AutoCAD_Files.
DATE_MODIFIED")

Dim daAdapter1 As OleDbDataAdapter = New OleDbDataAdapter
Dim daAdapter2 As OleDbDataAdapter = New OleDbDataAdapter
Dim daAdapter3 As OleDbDataAdapter = New OleDbDataAdapter

Public Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles btnLoad.Click
Dim Command1 As OleDbCommand = New OleDbCommand("SELECT * FROM
AutoCAD_Files", Connection1)

Connection1.Open()
Command1.Connection = Connection1

' Check if a drawing number range is selected
If ComboBox1.SelectedItem <> "" And ComboBox2.SelectedItem <> "" Then
Dim FromRange As String
Dim ToRange As String
Dim SQLRange As String
FromRange = Trim(UCase(ComboBox1.SelectedItem))
ToRange = Trim(UCase(ComboBox2.SelectedItem))
SQLRange = "SELECT * FROM AutoCAD_Files WHERE FILE_NAME BETWEEN
""" & FromRange & """ AND """ & ToRange & """"
Dim Command3 As OleDbCommand = New OleDbCommand(SQLRange,
Connection1)
daAdapter3.SelectCommand = Command3
DataGrid1.Visible = True
daAdapter3.Fill(dataset1, "AutoCAD_Files")
DataGrid1.SetDataBinding(dataset1, "AutoCAD_Files")
editID.DataBindings.Clear()
editID.DataBindings.Add(IDbinding)
editFILE_NAME.DataBindings.Clear()
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Clear()
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Clear()
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Clear()
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Clear()
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
editDATE_MODIFIED.DataBindings.Clear()
editDATE_MODIFIED.DataBindings.Add(DateModifiedbin ding)
Me.lblNavLocation.Text = (((Me.BindingContext(dataset1,
"AutoCAD_Files").Position + 1).ToString + " of ") _
+ Me.BindingContext(dataset1, "AutoCAD_Files").Count.
ToString)
Connection1.Close()
Exit Sub
End If

' Check if a drawing number is specified
If txtDrawingNum.Text <> "" Then
Dim SearchString As String
Dim SQL As String
SearchString = Trim(UCase(txtDrawingNum.Text))
SQL = "SELECT * FROM AutoCAD_Files WHERE FILE_NAME LIKE """ &
SearchString & """"
Dim command2 As OleDbCommand = New OleDbCommand(SQL, Connection1)
daAdapter2.SelectCommand = command2
DataGrid1.Visible = True
daAdapter2.Fill(dataset1, "AutoCAD_Files")
DataGrid1.SetDataBinding(dataset1, "AutoCAD_Files")
editID.DataBindings.Clear()
editID.DataBindings.Add(IDbinding)
editFILE_NAME.DataBindings.Clear()
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Clear()
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Clear()
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Clear()
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Clear()
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
editDATE_MODIFIED.DataBindings.Clear()
editDATE_MODIFIED.DataBindings.Add(DateModifiedbin ding)
Me.lblNavLocation.Text = (((Me.BindingContext(dataset1,
"AutoCAD_Files").Position + 1).ToString + " of ") _
+ Me.BindingContext(dataset1, "AutoCAD_Files").Count.
ToString)
Connection1.Close()
Exit Sub
End If

daAdapter1.SelectCommand = Command1
DataGrid1.Visible = True
daAdapter1.Fill(dataset1, "AutoCAD_Files")
DataGrid1.SetDataBinding(dataset1, "AutoCAD_Files")

editID.DataBindings.Clear()
editID.DataBindings.Add(IDbinding)
editFILE_NAME.DataBindings.Clear()
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Clear()
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Clear()
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Clear()
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Clear()
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
editDATE_MODIFIED.DataBindings.Clear()
editDATE_MODIFIED.DataBindings.Add(DateModifiedbin ding)

Me.lblNavLocation.Text = (((Me.BindingContext(dataset1,
"AutoCAD_Files").Position + 1).ToString + " of ") _
+ Me.BindingContext(dataset1, "AutoCAD_Files").Count.
ToString)
Connection1.Close()
Exit Sub
End Sub

Private Sub btnClearForm_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnClearForm.Click
dataset1.Clear()
DataGrid1.Hide()
lblNavLocation.Text = ""
txtNumber_of_Drawings.Text = ""
txtDrawingNum.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
End Sub
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
1 1837
Hi,

That is a lot of code, however know that a fill does not renew a dataset. It
adds what it gets new.

If this is not the answer, than you would to make it possible to help you in
my opinion bring it first back to for us as well understandable code
(probably you find it than yourself)

I hope this helps something,

Cor
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1557
by: Vishy | last post by:
Hi One of the less documented features of xpath is how to run multiple search on nodes or attributes e.g <Book name="Harry Potter" price="10GBP"/> <Book name="Harry Potter" price="5USD"/> now...
2
3230
by: Scott Tenorman | last post by:
Can I access/update a single dataset in a multi-threaded envirnment using C#? I'm assuming this is possible, but don't know how to go about it. This scenario is hypothetical so I can't give any...
0
1618
by: | last post by:
Hi, I have an app that uses a typed dataset to persist user data. The dataset has a multiple tables with multiple table relations. The problem I am running into is that the user data is...
1
18233
by: Brian | last post by:
I have a dataset containing 2 tables. I need to fill a datagrid using data from both of these. If I could create a SQL Statement to fill the datagrid, it would look like this: SELECT...
0
1279
by: John Bailey | last post by:
I have a dataset with multiple data tables. I need to bind this to a wizard interface, where each portion of the wizard udates the information in one of the datatables. I am using formviews in...
10
5624
by: jaYPee | last post by:
does anyone experienced slowness when updating a dataset using AcceptChanges? when calling this code it takes many seconds to update the database SqlDataAdapter1.Update(DsStudentCourse1)...
3
2739
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality...
1
8137
by: Casey | last post by:
Hi, How would one allow for possible multiple search criteria using FREETEXTTABLE. For example, my table "listings" has a full-text search catalog, and I may want to: SELECT * FROM listings...
1
1377
by: Andrea | last post by:
I have a data structure composed with a dataset with multiple tables connected through relationship. I'm using different table adapters of the dataset for load table, but when i use the select...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7009
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.