Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'Alimentation combox
Dim connetionString As String
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & chemin & "\Data.mdb"
Dim oledbCnn As OleDbConnection
oledbCnn = New OleDbConnection(connetionString)
oledbCnn.Open()
Dim oledbCmd As OleDbCommand
Dim ole As String
ole = " Select * from mail"
Try
oledbCmd = New OleDbCommand(ole, oledbCnn)
Dim oledbReader As OleDbDataReader = oledbCmd.ExecuteReader()
Dim snom = oledbReader.GetString("nom")
While oledbReader.Read
ComboBox2.Items.Add(snom)
End While
oledbReader.Close()
oledbCmd.Dispose()
oledbCnn.Close()
Catch ex As Exception
MsgBox("Impossible d'ouvrir la connection ! ")
End Try
End Sub
End Class
Imports System.Data.OleDb
Public Class Form1
'Connection base de donnée
Dim chemin As String = "C:\Bdd envoie mail"
Dim cnn As New OleDb.OleDbConnection
cnn = New OleDb.OleDbConnection
Imports System.Net.Mail
Imports System.Data.OleDb
Public Class Form1
Dim chemin As String = "C:\Bdd envoie mail"
Dim cnn As New OleDb.OleDbConnection
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = My.Settings.Adresse_mail
MaskedTextBox1.Text = My.Settings.Mdp_mail
ComboBox1.Text = My.Settings.Serveur_smtp
If My.Settings.Adresse_mail = "" Then
Label11.Visible = True
ElseIf Label11.Visible = True Then
Btnvoir.Text = "Ajouter une adresse mail"
End If
'Connection base de donnée
cnn = New OleDb.OleDbConnection
cnn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source =" & chemin & "\Data.mdb"
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM mail ", cnn)
Dim dt As New DataTable
da.Fill(dt)
Me.Dgvdata.DataSource = dt
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'Alimentation combox
Dim connetionString As String
connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & chemin & "\Data.mdb"
Dim oledbCnn As OleDbConnection
oledbCnn = New OleDbConnection(connetionString)
If cnn.State = ConnectionState.Open Then
cnn.Close()
Else
oledbCnn.Open()
End If
Dim oledbCmd As OleDbCommand
Dim ole As String
ole = " Select * from mail"
Try
oledbCmd = New OleDbCommand(ole, oledbCnn)
Dim oledbReader As OleDbDataReader = oledbCmd.ExecuteReader()
Dim snom = oledbReader.GetString(CInt("nom"))
While oledbReader.Read
ComboBox2.Items.Add(snom)
End While
oledbReader.Close()
oledbCmd.Dispose()
oledbCnn.Close()
Catch ex As Exception
MsgBox("Impossible d'ouvrir la connection ! ")
End Try
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim da As New OleDb.OleDbDataAdapter("SELECT * FROM mail ", cnn)
Dim dt As New DataTable
da.Fill(dt)
Me.Dgvdata.DataSource = dt
combobox2.DataSource = dt
ComboBox2.ValueMember = "Le nom du champ qui correspond"