By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,815 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,815 IT Pros & Developers. It's quick & easy.

What does this error message mean?

P: n/a
I have developed a form that would allow the user to load and search a
database several ways, by data range, by specific number or all database
entries. I can successfully load any of the ways once. But when I click a
button labeled "Clear Form" and then attempt to load data again I get the
following error message:

An unhandled exception of type 'System.ArgumentException' occurred in system.
windows.forms.dll

Additional information: This would cause two bindings in the collection to
bind to the same property.

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

Public Class frmDataEntry
Inherits System.Windows.Forms.Form
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)
Private Sub frmDataEntry_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lblNavLocation.Text = ""
End Sub
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

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

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")

' 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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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
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
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

Everytime you press btnload the program binds a bunch of controls to
the data. Next time you press the button it tries to bind the data again
and you get an error. I would call the databindings.clear method before I
bind the data.

For example

editFILE_DESCRIPTION.DataBindings.clear
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
Ken
---------------------
"Frustrated Developer via DotNetMonster.com" <fo***@DotNetMonster.com> wrote
in message news:54***********@DotNetMonster.com...
I have developed a form that would allow the user to load and search a
database several ways, by data range, by specific number or all database
entries. I can successfully load any of the ways once. But when I click a
button labeled "Clear Form" and then attempt to load data again I get the
following error message:

An unhandled exception of type 'System.ArgumentException' occurred in
system.
windows.forms.dll

Additional information: This would cause two bindings in the collection to
bind to the same property.

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

Public Class frmDataEntry
Inherits System.Windows.Forms.Form
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)
Private Sub frmDataEntry_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
lblNavLocation.Text = ""
End Sub
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

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

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")

' 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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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.Add(IDbinding)
editFILE_NAME.DataBindings.Add(FileNamebinding)
editFILE_TITLE.DataBindings.Add(FileTitlebinding)
editFILE_DESCRIPTION.DataBindings.Add(FileDescbind ing)
editREV_LETTER.DataBindings.Add(RevLetterbinding)
editORIGINATION_DATE.DataBindings.Add(OrigDatebind ing)
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
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 #2

P: n/a
Ken Tucker [MVP] wrote:
Hi,

Everytime you press btnload the program binds a bunch of controls to
the data. Next time you press the button it tries to bind the data again
and you get an error. I would call the databindings.clear method before I
bind the data.

For example

editFILE_DESCRIPTION.DataBindings.clear
editFILE_DESCRIPTION.DataBindings.Add(FileDescbin ding)

Ken
Thanks for the assistance. I've added the databindings.clear() statement to
all of my textbox fields. 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?

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)

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

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

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")

' 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---------------------
I have developed a form that would allow the user to load and search a
database several ways, by data range, by specific number or all database

[quoted text clipped - 152 lines]
ComboBox2.Text = ""
End Sub

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #3

P: n/a
Hi,

I would add another textbox for searching. Here is an example
on finding records

http://www.windowsformsdatagridhelp....7-26a58190eb5c

Ken
---------------------
"Frustrated Developer via DotNetMonster.com" <fo***@DotNetMonster.com> wrote
in message news:54***********@DotNetMonster.com...
Ken Tucker [MVP] wrote:
Hi,

Everytime you press btnload the program binds a bunch of controls
to
the data. Next time you press the button it tries to bind the data again
and you get an error. I would call the databindings.clear method before I
bind the data.

For example

editFILE_DESCRIPTION.DataBindings.clear
editFILE_DESCRIPTION.DataBindings.Add(FileDescbi nding)

Ken


Thanks for the assistance. I've added the databindings.clear() statement
to
all of my textbox fields. 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?

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)

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

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

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")

' 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
---------------------
I have developed a form that would allow the user to load and search a
database several ways, by data range, by specific number or all database

[quoted text clipped - 152 lines]
ComboBox2.Text = ""
End Sub

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.