I have posted a couple times on here already and found the user community to
be very helpful. I took on a project before I realized how difficult a time
I'm having working with a database. Assistance would be greatly appreciated!
I am trying to allow certain users to be able to preview a database's
contents without being able to update which I've accomplished. I've created a
"Preview" button and set the datagrid to READ ONLY. Now I want to be able to
enable certain users to create new entries in the database. I have a Combo
Box field with items representing data ranges (ex. 100xxx, 200xxx, 300xxx etc.
) representing AutoCAD drawing numbers. I'd like to be able to selectively
sort the database based on a range if they choose one in the Combo Box. I
also have a Text field which the user can enter a specified drawing number
(ex. 123456) and have the app search the database and display only that entry.
I'm using a datagrid to display the results. I can pull up the entire
database, but cannot figure out how to sort based on entries in the combo box
or text fields.
In addition I used the Data Form Wizard to create individual field text boxes
and the Navigate (<<, <, >, >>) buttons for the same database on the same
form at the bottom. I'd like it if the user could use either the datagrid or
the individual fields to perform data entry. Unfortunately I can't seem to
link the fields with the database entries. I can specify a row and write that
to the text boxes but that's by hard coding it. I'd like to be able to just
navigate through the database using the Navigate buttons.
Public Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles btnLoad.Click
Dim dataset1 As New DataSet1
'Dim dataset2 As New DataSet
'dataset2 = New DataSet("dataset2")
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 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
daAdapter1.SelectCommand = Command1
DataGrid1.Visible = True
daAdapter1.Fill(dataset1, "AutoCAD Files")
DataGrid1.SetDataBinding(dataset1, "AutoCAD Files")
' Check if a drawing number range is selected
'If ComboBox1.SelectedItem <> "" Then
'Dim Command2 As OleDbCommand = New OleDbCommand("SELECT * FROM
[AutoCAD Files] where [File Name] LIKE [combobox1.selecteditem]", Connection1)
'End If
' Check if a drawing number is specified
If TextBox3.Text <> "" Then
'Dim command2 As OleDbCommand = New OleDbCommand("select * from
[AutoCAD Files] where [FILE NAME] like " & Trim(TextBox3.Text) & "",
Connection1)
daAdapter2.SelectCommand = command2
daAdapter2.Fill(dataset1, "AutoCAD Files")
DataGrid1.SetDataBinding(dataset1, "AutoCAD Files")
End If
'editID.Text = dataset1.Tables("AutoCAD Files").Rows(0).Item(0)
'editFILE_NAME.Text = dataset1.Tables("AutoCAD Files").Rows(0).Item(1)
'editFILE_TITLE.Text = dataset1.Tables("AutoCAD Files").Rows(0).Item
(2)
'editFILE_DESCRIPTION.Text = dataset1.Tables("AutoCAD Files").Rows(0).
Item(3)
'editREV_LETTER.Text = dataset1.Tables("AutoCAD Files").Rows(0).Item
(4)
'editORIGINATION_DATE.Text = dataset1.Tables("AutoCAD Files").Rows(0).
Item(5)
'editDATE_MODIFIED.Text = dataset1.Tables("AutoCAD Files").Rows(0).
Item(7)
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCancel.Click
Me.BindingContext(objDataSet1, "AutoCAD Files").CancelCurrentEdit()
Me.objDataSet1_PositionChanged()
ActiveForm.Hide()
End Sub
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200509/1