1 Replies - 154 Views - Last Post: 05 February 2018 - 02:02 PM Rate Topic: -----

#1 rubenfrreis  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-February 18

VB.net insert data to relationship row

Posted 05 February 2018 - 01:58 PM

Hi Guys,


I want to create a list a listbox on my form and next add some numbers to that listbox (I can do that), but the problem is
to insert all that number in that listbox and send to my access data base with a relationship.

Here some screenshots to better understanding:

[img]https://image.ibb.co/hKChvc/Capture.png[/img]

My code:

Imports System.Data.OleDb

Public Class Form1

    Dim provider As String
    Dim datafile As String
    Dim connString As String
    Dim myConnection As OleDbConnection = New OleDbConnection



    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database2DataSet.Moradas' table. You can move, or remove it, as needed.
        Me.MoradasTableAdapter.Fill(Me.Database2DataSet.Moradas)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        provider = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source="
        datafile = "C:\Users\RR\Documents\Database2.mdb"
        connString = provider & datafile
        myConnection.ConnectionString = connString
        myConnection.Open()
        Dim str As String
        str = "Insert into Guias([Remetente],[Destinatário]) Values (?,?)"
        Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
        cmd.Parameters.Add(New OleDbParameter("Remetente", CType(ComboBox1.Text, String)))
        cmd.Parameters.Add(New OleDbParameter("Destinatário", CType(ComboBox2.Text, String)))


Is This A Good Question/Topic? 0
  • +

Replies To: VB.net insert data to relationship row

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13755
  • View blog
  • Posts: 54,924
  • Joined: 12-June 08

Re: VB.net insert data to relationship row

Posted 05 February 2018 - 02:02 PM

I am not following - whatis your question?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1