473,624 Members | 2,249 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.t ext 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.Ole Db

+ Windows Form Designer generated code

Dim dataset1 As New DataSet1
Dim ConnectionStrin g As String = "Provider=Micro soft.Jet.OLEDB. 4.0; Data
Source = C:\AutoCAD Project\AutoCAD _Files.mdb; User ID=Admin"
Dim Connection1 As OleDbConnection = New OleDbConnection (ConnectionStri ng)
Dim IDbinding As New Binding("Text", dataset1, "AutoCAD_Files. ID")
Dim FileNamebinding As New Binding("Text", dataset1, "AutoCAD_Fi les.
FILE_NAME")
Dim FileTitlebindin g As New Binding("Text", dataset1, "AutoCAD_Fi les.
FILE_TITLE")
Dim FileDescbinding As New Binding("Text", dataset1, "AutoCAD_Fi les.
FILE_DESCRIPTIO N")
Dim RevLetterbindin g As New Binding("Text", dataset1, "AutoCAD_Fi les.
REV_LETTER")
Dim OrigDatebinding As New Binding("Text", dataset1, "AutoCAD_Fi les.
ORIGINATION_DAT E")
Dim DateModifiedbin ding As New Binding("Text", dataset1, "AutoCAD_Fi les.
DATE_MODIFIED")

Dim daAdapter1 As OleDbDataAdapte r = New OleDbDataAdapte r
Dim daAdapter2 As OleDbDataAdapte r = New OleDbDataAdapte r
Dim daAdapter3 As OleDbDataAdapte r = New OleDbDataAdapte r

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

Connection1.Ope n()
Command1.Connec tion = Connection1

' Check if a drawing number range is selected
If ComboBox1.Selec tedItem <> "" And ComboBox2.Selec tedItem <> "" Then
Dim FromRange As String
Dim ToRange As String
Dim SQLRange As String
FromRange = Trim(UCase(Comb oBox1.SelectedI tem))
ToRange = Trim(UCase(Comb oBox2.SelectedI tem))
SQLRange = "SELECT * FROM AutoCAD_Files WHERE FILE_NAME BETWEEN
""" & FromRange & """ AND """ & ToRange & """"
Dim Command3 As OleDbCommand = New OleDbCommand(SQ LRange,
Connection1)
daAdapter3.Sele ctCommand = Command3
DataGrid1.Visib le = True
daAdapter3.Fill (dataset1, "AutoCAD_Files" )
DataGrid1.SetDa taBinding(datas et1, "AutoCAD_Files" )
editID.DataBind ings.Clear()
editID.DataBind ings.Add(IDbind ing)
editFILE_NAME.D ataBindings.Cle ar()
editFILE_NAME.D ataBindings.Add (FileNamebindin g)
editFILE_TITLE. DataBindings.Cl ear()
editFILE_TITLE. DataBindings.Ad d(FileTitlebind ing)
editFILE_DESCRI PTION.DataBindi ngs.Clear()
editFILE_DESCRI PTION.DataBindi ngs.Add(FileDes cbinding)
editREV_LETTER. DataBindings.Cl ear()
editREV_LETTER. DataBindings.Ad d(RevLetterbind ing)
editORIGINATION _DATE.DataBindi ngs.Clear()
editORIGINATION _DATE.DataBindi ngs.Add(OrigDat ebinding)
editDATE_MODIFI ED.DataBindings .Clear()
editDATE_MODIFI ED.DataBindings .Add(DateModifi edbinding)
Me.lblNavLocati on.Text = (((Me.BindingCo ntext(dataset1,
"AutoCAD_Files" ).Position + 1).ToString + " of ") _
+ Me.BindingConte xt(dataset1, "AutoCAD_Files" ).Count.
ToString)
Connection1.Clo se()
Exit Sub
End If

' Check if a drawing number is specified
If txtDrawingNum.T ext <> "" Then
Dim SearchString As String
Dim SQL As String
SearchString = Trim(UCase(txtD rawingNum.Text) )
SQL = "SELECT * FROM AutoCAD_Files WHERE FILE_NAME LIKE """ &
SearchString & """"
Dim command2 As OleDbCommand = New OleDbCommand(SQ L, Connection1)
daAdapter2.Sele ctCommand = command2
DataGrid1.Visib le = True
daAdapter2.Fill (dataset1, "AutoCAD_Files" )
DataGrid1.SetDa taBinding(datas et1, "AutoCAD_Files" )
editID.DataBind ings.Clear()
editID.DataBind ings.Add(IDbind ing)
editFILE_NAME.D ataBindings.Cle ar()
editFILE_NAME.D ataBindings.Add (FileNamebindin g)
editFILE_TITLE. DataBindings.Cl ear()
editFILE_TITLE. DataBindings.Ad d(FileTitlebind ing)
editFILE_DESCRI PTION.DataBindi ngs.Clear()
editFILE_DESCRI PTION.DataBindi ngs.Add(FileDes cbinding)
editREV_LETTER. DataBindings.Cl ear()
editREV_LETTER. DataBindings.Ad d(RevLetterbind ing)
editORIGINATION _DATE.DataBindi ngs.Clear()
editORIGINATION _DATE.DataBindi ngs.Add(OrigDat ebinding)
editDATE_MODIFI ED.DataBindings .Clear()
editDATE_MODIFI ED.DataBindings .Add(DateModifi edbinding)
Me.lblNavLocati on.Text = (((Me.BindingCo ntext(dataset1,
"AutoCAD_Files" ).Position + 1).ToString + " of ") _
+ Me.BindingConte xt(dataset1, "AutoCAD_Files" ).Count.
ToString)
Connection1.Clo se()
Exit Sub
End If

daAdapter1.Sele ctCommand = Command1
DataGrid1.Visib le = True
daAdapter1.Fill (dataset1, "AutoCAD_Files" )
DataGrid1.SetDa taBinding(datas et1, "AutoCAD_Files" )

editID.DataBind ings.Clear()
editID.DataBind ings.Add(IDbind ing)
editFILE_NAME.D ataBindings.Cle ar()
editFILE_NAME.D ataBindings.Add (FileNamebindin g)
editFILE_TITLE. DataBindings.Cl ear()
editFILE_TITLE. DataBindings.Ad d(FileTitlebind ing)
editFILE_DESCRI PTION.DataBindi ngs.Clear()
editFILE_DESCRI PTION.DataBindi ngs.Add(FileDes cbinding)
editREV_LETTER. DataBindings.Cl ear()
editREV_LETTER. DataBindings.Ad d(RevLetterbind ing)
editORIGINATION _DATE.DataBindi ngs.Clear()
editORIGINATION _DATE.DataBindi ngs.Add(OrigDat ebinding)
editDATE_MODIFI ED.DataBindings .Clear()
editDATE_MODIFI ED.DataBindings .Add(DateModifi edbinding)

Me.lblNavLocati on.Text = (((Me.BindingCo ntext(dataset1,
"AutoCAD_Files" ).Position + 1).ToString + " of ") _
+ Me.BindingConte xt(dataset1, "AutoCAD_Files" ).Count.
ToString)
Connection1.Clo se()
Exit Sub
End Sub

Private Sub btnClearForm_Cl ick(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles btnClearForm.Cl ick
dataset1.Clear( )
DataGrid1.Hide( )
lblNavLocation. Text = ""
txtNumber_of_Dr awings.Text = ""
txtDrawingNum.T ext = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
End Sub
--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
1 1848
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
1564
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 if you want one of them following is xpath query ..//Book
2
3244
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 specific code examples. I believe there is an article about in using VB.NET, but I haven't seen it in a while. If anyone has any insights into this I would appreciate it!
0
1626
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 dynamic and is not predictable at design time. What I mean by this is the forms that user inputs data is not static - it changes dynamically at runtime based on user input. This makes it difficult to persist the data in a dataset with multiple...
1
18241
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 fields.fieldname, fieldvalues.value FROM fields, fieldvalues I am having trouble finding documentation explaining how to populate
0
1291
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 each screen of the wizard since this seems to be the only way to databind anything in ASP.Net 2.0. I could not set the datasource to go against the dataset directly, since the methods to populate the dataset are in the dataadapter objects, and...
10
5656
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) DsStudentCourse1.AcceptChanges() i'm also wondering because w/ out AcceptChanges the data is still save into the database and it is now faster.
3
2748
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 (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
1
8158
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 WHERE name LIKE @name AND city LIKE @city I've got it working to select only by name: SELECT listing_id, RANK, name, address, city, zip, heading, phone FROM listings a,
1
1381
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 method on master table ,data store in the other table are not filter. I think that when there are relation with table a filter apply on table have effect on the relate table drive by relation. Any suggestions? Regards Andrea
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8619
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4078
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2604
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 we have to send another system
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.