Using Dataset and table adapters for Service Based Database in Visual Studio 2017 and VB.net

499 Views Asked by At

I am trying to create a Windows form with a self contained DB. I added a Service Based DataBase. I then created a Dataset. My table is simple:

Example: columns are: Model (PK), Part1, Part2, Part3............

I want a combobox on my for to be able to select the model, and another combobox to select the desired part then return the number. You pick Model 740, and Part1 and the return is part1 part number.

The issue is that I need the select Statement in the tableadapter query builder to show something like this.

SELECT * FROM Table WHERE Model = ? (Paramter from ComboBox1) AND parameter (Part1 From Combobox2 Will be a Column Name)

I can't figure out how or if it is even possible to have a parameter in after the select.

Table is built like this: [enter image description here][1] [1]: https://i.stack.imgur.com/bf4kv.png

1

There are 1 best solutions below

3
Keith Hyder On

I got it figured out

'TODO: This line of code loads data into the 'CSDataset.CryoSeries' table. You can move, or remove it, as needed. Me.CryoSeriesTableAdapter.Fill(Me.CSDataset.CryoSeries)

    'Pulling Data From Table Adapter       
    Dim db As New DataTables.CSDatasetTableAdapters.CryoSeriesTableAdapter
    Dim result = db.GetData
    Dim Model As String = CBmodel.Text.Trim
    Dim Part As String = CBPart.Text.Trim

    TBresult.Text = result.Rows(0).Item(Part)