erreur "ExecuteReader: Connection property has not been initialized."
mon code est le suivant:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open()
Dim cmd As New OleDbCommand
cmd = New OleDbCommand
cmd.CommandText = "select * from Article"
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
End Sub
End Class
erreur "ExecuteReader: Connection property has not been initialized."
mon code est le suivant:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open()
Dim cmd As New OleDbCommand
cmd = New OleDbCommand
cmd.CommandText = "select * from Article"
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
End Sub
End Class
erreur "ExecuteReader: Connection property has not been initialized."
mon code est le suivant:
Imports System.Data.OleDb
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
Me.ComboBox1.Text = "ComboBox1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As New OleDbConnection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open()
Dim cmd As New OleDbCommand
cmd = New OleDbCommand
cmd.CommandText = "select * from Article"
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
End Sub
End Class
Bonjour tijani sellami
Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' ********* Ton code
' Dim conn As New OleDbConnection
' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
' conn.Open()
' Dim cmd As New OleDbCommand
' cmd = New OleDbCommand
' cmd.CommandText = "select * from Article"
' Dim dr As OleDbDataReader
' dr = cmd.ExecuteReader()
' ********* Le mien
Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open() ' Connexion effective via fournisseur OLEDB
cmd = conn.CreateCommand() ' Création effective de Command
cmd.CommandType = CommandType.Text ' Désignation du type de commande
cmd.CommandText = "select * from Article"
dr = cmd.ExecuteReader()
' ********* La suite inchangée, sauf ...
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
' ********* ... sauf qu'il ne faut oublier de fermer la connexion
cmd.Close()
End Sub
Cela dervait mieux fonctionner comme ça.
Bonne chance
phrscx
"tijani sellami" a écrit :
> erreur "ExecuteReader: Connection property has not been initialized."
> mon code est le suivant:
> Imports System.Data.OleDb
>
> Public Class Form1
> Inherits System.Windows.Forms.Form
>
> #Region " Code généré par le Concepteur Windows Form "
>
> Public Sub New()
> MyBase.New()
>
> 'Cet appel est requis par le Concepteur Windows Form.
> InitializeComponent()
>
> 'Ajoutez une initialisation quelconque après l'appel
> InitializeComponent()
>
> End Sub
>
> 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> composants.
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> If disposing Then
> If Not (components Is Nothing) Then
> components.Dispose()
> End If
> End If
> MyBase.Dispose(disposing)
> End Sub
>
> 'Requis par le Concepteur Windows Form
> Private components As System.ComponentModel.IContainer
>
> 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> Form
> 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> 'Ne la modifiez pas en utilisant l'éditeur de code.
> Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.ComboBox1 = New System.Windows.Forms.ComboBox
> Me.SuspendLayout()
> '
> 'ComboBox1
> '
> Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> Me.ComboBox1.Name = "ComboBox1"
> Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> Me.ComboBox1.TabIndex = 0
> Me.ComboBox1.Text = "ComboBox1"
> '
> 'Form1
> '
> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> Me.ClientSize = New System.Drawing.Size(292, 266)
> Me.Controls.Add(Me.ComboBox1)
> Me.Name = "Form1"
> Me.Text = "Form1"
> Me.ResumeLayout(False)
>
> End Sub
>
> #End Region
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim conn As New OleDbConnection
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> conn.Open()
> Dim cmd As New OleDbCommand
> cmd = New OleDbCommand
> cmd.CommandText = "select * from Article"
> Dim dr As OleDbDataReader
> dr = cmd.ExecuteReader()
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
>
> End Sub
> End Class
>
Bonjour tijani sellami
Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' ********* Ton code
' Dim conn As New OleDbConnection
' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
' conn.Open()
' Dim cmd As New OleDbCommand
' cmd = New OleDbCommand
' cmd.CommandText = "select * from Article"
' Dim dr As OleDbDataReader
' dr = cmd.ExecuteReader()
' ********* Le mien
Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open() ' Connexion effective via fournisseur OLEDB
cmd = conn.CreateCommand() ' Création effective de Command
cmd.CommandType = CommandType.Text ' Désignation du type de commande
cmd.CommandText = "select * from Article"
dr = cmd.ExecuteReader()
' ********* La suite inchangée, sauf ...
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
' ********* ... sauf qu'il ne faut oublier de fermer la connexion
cmd.Close()
End Sub
Cela dervait mieux fonctionner comme ça.
Bonne chance
phrscx
"tijani sellami" a écrit :
> erreur "ExecuteReader: Connection property has not been initialized."
> mon code est le suivant:
> Imports System.Data.OleDb
>
> Public Class Form1
> Inherits System.Windows.Forms.Form
>
> #Region " Code généré par le Concepteur Windows Form "
>
> Public Sub New()
> MyBase.New()
>
> 'Cet appel est requis par le Concepteur Windows Form.
> InitializeComponent()
>
> 'Ajoutez une initialisation quelconque après l'appel
> InitializeComponent()
>
> End Sub
>
> 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> composants.
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> If disposing Then
> If Not (components Is Nothing) Then
> components.Dispose()
> End If
> End If
> MyBase.Dispose(disposing)
> End Sub
>
> 'Requis par le Concepteur Windows Form
> Private components As System.ComponentModel.IContainer
>
> 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> Form
> 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> 'Ne la modifiez pas en utilisant l'éditeur de code.
> Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.ComboBox1 = New System.Windows.Forms.ComboBox
> Me.SuspendLayout()
> '
> 'ComboBox1
> '
> Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> Me.ComboBox1.Name = "ComboBox1"
> Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> Me.ComboBox1.TabIndex = 0
> Me.ComboBox1.Text = "ComboBox1"
> '
> 'Form1
> '
> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> Me.ClientSize = New System.Drawing.Size(292, 266)
> Me.Controls.Add(Me.ComboBox1)
> Me.Name = "Form1"
> Me.Text = "Form1"
> Me.ResumeLayout(False)
>
> End Sub
>
> #End Region
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim conn As New OleDbConnection
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> conn.Open()
> Dim cmd As New OleDbCommand
> cmd = New OleDbCommand
> cmd.CommandText = "select * from Article"
> Dim dr As OleDbDataReader
> dr = cmd.ExecuteReader()
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
>
> End Sub
> End Class
>
Bonjour tijani sellami
Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' ********* Ton code
' Dim conn As New OleDbConnection
' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
' conn.Open()
' Dim cmd As New OleDbCommand
' cmd = New OleDbCommand
' cmd.CommandText = "select * from Article"
' Dim dr As OleDbDataReader
' dr = cmd.ExecuteReader()
' ********* Le mien
Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=E:DOTNETVBExemplestock.mdb;"
conn.Open() ' Connexion effective via fournisseur OLEDB
cmd = conn.CreateCommand() ' Création effective de Command
cmd.CommandType = CommandType.Text ' Désignation du type de commande
cmd.CommandText = "select * from Article"
dr = cmd.ExecuteReader()
' ********* La suite inchangée, sauf ...
While dr.Read()
MsgBox(dr(0))
MsgBox(dr(1))
MsgBox(dr(2))
' loading data into TextBoxes by column index
End While
' ********* ... sauf qu'il ne faut oublier de fermer la connexion
cmd.Close()
End Sub
Cela dervait mieux fonctionner comme ça.
Bonne chance
phrscx
"tijani sellami" a écrit :
> erreur "ExecuteReader: Connection property has not been initialized."
> mon code est le suivant:
> Imports System.Data.OleDb
>
> Public Class Form1
> Inherits System.Windows.Forms.Form
>
> #Region " Code généré par le Concepteur Windows Form "
>
> Public Sub New()
> MyBase.New()
>
> 'Cet appel est requis par le Concepteur Windows Form.
> InitializeComponent()
>
> 'Ajoutez une initialisation quelconque après l'appel
> InitializeComponent()
>
> End Sub
>
> 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> composants.
> Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> If disposing Then
> If Not (components Is Nothing) Then
> components.Dispose()
> End If
> End If
> MyBase.Dispose(disposing)
> End Sub
>
> 'Requis par le Concepteur Windows Form
> Private components As System.ComponentModel.IContainer
>
> 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> Form
> 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> 'Ne la modifiez pas en utilisant l'éditeur de code.
> Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> <System.Diagnostics.DebuggerStepThrough()> Private Sub
> InitializeComponent()
> Me.ComboBox1 = New System.Windows.Forms.ComboBox
> Me.SuspendLayout()
> '
> 'ComboBox1
> '
> Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> Me.ComboBox1.Name = "ComboBox1"
> Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> Me.ComboBox1.TabIndex = 0
> Me.ComboBox1.Text = "ComboBox1"
> '
> 'Form1
> '
> Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> Me.ClientSize = New System.Drawing.Size(292, 266)
> Me.Controls.Add(Me.ComboBox1)
> Me.Name = "Form1"
> Me.Text = "Form1"
> Me.ResumeLayout(False)
>
> End Sub
>
> #End Region
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim conn As New OleDbConnection
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> conn.Open()
> Dim cmd As New OleDbCommand
> cmd = New OleDbCommand
> cmd.CommandText = "select * from Article"
> Dim dr As OleDbDataReader
> dr = cmd.ExecuteReader()
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
>
> End Sub
> End Class
>
merci.
maitenant je veux connecter une base Oracle.
mon code est le suivant:
Imports System.Data
Imports System.Data.OracleClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As OracleConnection
Dim cmd As OracleCommand
Dim dr As OracleDataReader
conn = New OracleConnection("Data Source=Oracle8i; User Id=scott;
Password=tiger; Integrated Security=no;")
conn.Open()
cmd = New OracleCommand("Select * from article", conn)
dr = cmd.ExecuteReader()
ComboBox1.Items.Clear()
While dr.Read()
ComboBox1.Items.Add(dr(1))
End While
End Sub
End Class
l'erreur est la suivante au niveau de .open():
Une exception non gérée du type 'System.Data.OracleClient.OracleException'
s'est produite dans system.data.oracleclient.dll
Informations supplémentaires : Erreur système.
"phrscx" a écrit :
> Bonjour tijani sellami
>
> Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
> ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ' ********* Ton code
>
>
> ' Dim conn As New OleDbConnection
> ' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> ' conn.Open()
> ' Dim cmd As New OleDbCommand
> ' cmd = New OleDbCommand
> ' cmd.CommandText = "select * from Article"
> ' Dim dr As OleDbDataReader
> ' dr = cmd.ExecuteReader()
>
>
> ' ********* Le mien
>
> Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
> Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
> Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
>
> conn.Open() ' Connexion effective via fournisseur OLEDB
>
> cmd = conn.CreateCommand() ' Création effective de Command
> cmd.CommandType = CommandType.Text ' Désignation du type de commande
> cmd.CommandText = "select * from Article"
>
> dr = cmd.ExecuteReader()
>
>
> ' ********* La suite inchangée, sauf ...
>
>
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
> ' ********* ... sauf qu'il ne faut oublier de fermer la connexion
>
> cmd.Close()
>
> End Sub
>
> Cela dervait mieux fonctionner comme ça.
>
> Bonne chance
>
> phrscx
>
>
>
>
>
>
> "tijani sellami" a écrit :
>
> > erreur "ExecuteReader: Connection property has not been initialized."
> > mon code est le suivant:
> > Imports System.Data.OleDb
> >
> > Public Class Form1
> > Inherits System.Windows.Forms.Form
> >
> > #Region " Code généré par le Concepteur Windows Form "
> >
> > Public Sub New()
> > MyBase.New()
> >
> > 'Cet appel est requis par le Concepteur Windows Form.
> > InitializeComponent()
> >
> > 'Ajoutez une initialisation quelconque après l'appel
> > InitializeComponent()
> >
> > End Sub
> >
> > 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> > composants.
> > Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> > If disposing Then
> > If Not (components Is Nothing) Then
> > components.Dispose()
> > End If
> > End If
> > MyBase.Dispose(disposing)
> > End Sub
> >
> > 'Requis par le Concepteur Windows Form
> > Private components As System.ComponentModel.IContainer
> >
> > 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> > Form
> > 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> > 'Ne la modifiez pas en utilisant l'éditeur de code.
> > Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> > Me.ComboBox1 = New System.Windows.Forms.ComboBox
> > Me.SuspendLayout()
> > '
> > 'ComboBox1
> > '
> > Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> > Me.ComboBox1.Name = "ComboBox1"
> > Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> > Me.ComboBox1.TabIndex = 0
> > Me.ComboBox1.Text = "ComboBox1"
> > '
> > 'Form1
> > '
> > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> > Me.ClientSize = New System.Drawing.Size(292, 266)
> > Me.Controls.Add(Me.ComboBox1)
> > Me.Name = "Form1"
> > Me.Text = "Form1"
> > Me.ResumeLayout(False)
> >
> > End Sub
> >
> > #End Region
> >
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > Dim conn As New OleDbConnection
> >
> > conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=E:DOTNETVBExemplestock.mdb;"
> > conn.Open()
> > Dim cmd As New OleDbCommand
> > cmd = New OleDbCommand
> > cmd.CommandText = "select * from Article"
> > Dim dr As OleDbDataReader
> > dr = cmd.ExecuteReader()
> > While dr.Read()
> > MsgBox(dr(0))
> > MsgBox(dr(1))
> > MsgBox(dr(2))
> > ' loading data into TextBoxes by column index
> > End While
> >
> >
> > End Sub
> > End Class
> >
merci.
maitenant je veux connecter une base Oracle.
mon code est le suivant:
Imports System.Data
Imports System.Data.OracleClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As OracleConnection
Dim cmd As OracleCommand
Dim dr As OracleDataReader
conn = New OracleConnection("Data Source=Oracle8i; User Id=scott;
Password=tiger; Integrated Security=no;")
conn.Open()
cmd = New OracleCommand("Select * from article", conn)
dr = cmd.ExecuteReader()
ComboBox1.Items.Clear()
While dr.Read()
ComboBox1.Items.Add(dr(1))
End While
End Sub
End Class
l'erreur est la suivante au niveau de .open():
Une exception non gérée du type 'System.Data.OracleClient.OracleException'
s'est produite dans system.data.oracleclient.dll
Informations supplémentaires : Erreur système.
"phrscx" a écrit :
> Bonjour tijani sellami
>
> Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
> ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ' ********* Ton code
>
>
> ' Dim conn As New OleDbConnection
> ' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> ' conn.Open()
> ' Dim cmd As New OleDbCommand
> ' cmd = New OleDbCommand
> ' cmd.CommandText = "select * from Article"
> ' Dim dr As OleDbDataReader
> ' dr = cmd.ExecuteReader()
>
>
> ' ********* Le mien
>
> Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
> Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
> Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
>
> conn.Open() ' Connexion effective via fournisseur OLEDB
>
> cmd = conn.CreateCommand() ' Création effective de Command
> cmd.CommandType = CommandType.Text ' Désignation du type de commande
> cmd.CommandText = "select * from Article"
>
> dr = cmd.ExecuteReader()
>
>
> ' ********* La suite inchangée, sauf ...
>
>
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
> ' ********* ... sauf qu'il ne faut oublier de fermer la connexion
>
> cmd.Close()
>
> End Sub
>
> Cela dervait mieux fonctionner comme ça.
>
> Bonne chance
>
> phrscx
>
>
>
>
>
>
> "tijani sellami" a écrit :
>
> > erreur "ExecuteReader: Connection property has not been initialized."
> > mon code est le suivant:
> > Imports System.Data.OleDb
> >
> > Public Class Form1
> > Inherits System.Windows.Forms.Form
> >
> > #Region " Code généré par le Concepteur Windows Form "
> >
> > Public Sub New()
> > MyBase.New()
> >
> > 'Cet appel est requis par le Concepteur Windows Form.
> > InitializeComponent()
> >
> > 'Ajoutez une initialisation quelconque après l'appel
> > InitializeComponent()
> >
> > End Sub
> >
> > 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> > composants.
> > Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> > If disposing Then
> > If Not (components Is Nothing) Then
> > components.Dispose()
> > End If
> > End If
> > MyBase.Dispose(disposing)
> > End Sub
> >
> > 'Requis par le Concepteur Windows Form
> > Private components As System.ComponentModel.IContainer
> >
> > 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> > Form
> > 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> > 'Ne la modifiez pas en utilisant l'éditeur de code.
> > Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> > Me.ComboBox1 = New System.Windows.Forms.ComboBox
> > Me.SuspendLayout()
> > '
> > 'ComboBox1
> > '
> > Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> > Me.ComboBox1.Name = "ComboBox1"
> > Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> > Me.ComboBox1.TabIndex = 0
> > Me.ComboBox1.Text = "ComboBox1"
> > '
> > 'Form1
> > '
> > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> > Me.ClientSize = New System.Drawing.Size(292, 266)
> > Me.Controls.Add(Me.ComboBox1)
> > Me.Name = "Form1"
> > Me.Text = "Form1"
> > Me.ResumeLayout(False)
> >
> > End Sub
> >
> > #End Region
> >
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > Dim conn As New OleDbConnection
> >
> > conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=E:DOTNETVBExemplestock.mdb;"
> > conn.Open()
> > Dim cmd As New OleDbCommand
> > cmd = New OleDbCommand
> > cmd.CommandText = "select * from Article"
> > Dim dr As OleDbDataReader
> > dr = cmd.ExecuteReader()
> > While dr.Read()
> > MsgBox(dr(0))
> > MsgBox(dr(1))
> > MsgBox(dr(2))
> > ' loading data into TextBoxes by column index
> > End While
> >
> >
> > End Sub
> > End Class
> >
merci.
maitenant je veux connecter une base Oracle.
mon code est le suivant:
Imports System.Data
Imports System.Data.OracleClient
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Code généré par le Concepteur Windows Form "
Public Sub New()
MyBase.New()
'Cet appel est requis par le Concepteur Windows Form.
InitializeComponent()
'Ajoutez une initialisation quelconque après l'appel
InitializeComponent()
End Sub
'La méthode substituée Dispose du formulaire pour nettoyer la liste des
composants.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Requis par le Concepteur Windows Form
Private components As System.ComponentModel.IContainer
'REMARQUE : la procédure suivante est requise par le Concepteur Windows
Form
'Elle peut être modifiée en utilisant le Concepteur Windows Form.
'Ne la modifiez pas en utilisant l'éditeur de code.
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.SuspendLayout()
'
'ComboBox1
'
Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
Me.ComboBox1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Controls.Add(Me.ComboBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim conn As OracleConnection
Dim cmd As OracleCommand
Dim dr As OracleDataReader
conn = New OracleConnection("Data Source=Oracle8i; User Id=scott;
Password=tiger; Integrated Security=no;")
conn.Open()
cmd = New OracleCommand("Select * from article", conn)
dr = cmd.ExecuteReader()
ComboBox1.Items.Clear()
While dr.Read()
ComboBox1.Items.Add(dr(1))
End While
End Sub
End Class
l'erreur est la suivante au niveau de .open():
Une exception non gérée du type 'System.Data.OracleClient.OracleException'
s'est produite dans system.data.oracleclient.dll
Informations supplémentaires : Erreur système.
"phrscx" a écrit :
> Bonjour tijani sellami
>
> Voici le code de ta Sub Form1 dans lequel j'ai placé en commentaire ce qui
> ne me paraît suspect et dans lequel j'ai placé du code que je crois meilleur :
>
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> ' ********* Ton code
>
>
> ' Dim conn As New OleDbConnection
> ' conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
> ' conn.Open()
> ' Dim cmd As New OleDbCommand
> ' cmd = New OleDbCommand
> ' cmd.CommandText = "select * from Article"
> ' Dim dr As OleDbDataReader
> ' dr = cmd.ExecuteReader()
>
>
> ' ********* Le mien
>
> Dim conn As New OleDbConnection ' Instanciation d'un objet Connection
> Dim cmd As New OleDbCommand ' Instanciation d'un objet Command
> Dim dr As OleDbDataReader ' Déclaration d'un objet DataReader
>
> conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=E:DOTNETVBExemplestock.mdb;"
>
> conn.Open() ' Connexion effective via fournisseur OLEDB
>
> cmd = conn.CreateCommand() ' Création effective de Command
> cmd.CommandType = CommandType.Text ' Désignation du type de commande
> cmd.CommandText = "select * from Article"
>
> dr = cmd.ExecuteReader()
>
>
> ' ********* La suite inchangée, sauf ...
>
>
> While dr.Read()
> MsgBox(dr(0))
> MsgBox(dr(1))
> MsgBox(dr(2))
> ' loading data into TextBoxes by column index
> End While
>
> ' ********* ... sauf qu'il ne faut oublier de fermer la connexion
>
> cmd.Close()
>
> End Sub
>
> Cela dervait mieux fonctionner comme ça.
>
> Bonne chance
>
> phrscx
>
>
>
>
>
>
> "tijani sellami" a écrit :
>
> > erreur "ExecuteReader: Connection property has not been initialized."
> > mon code est le suivant:
> > Imports System.Data.OleDb
> >
> > Public Class Form1
> > Inherits System.Windows.Forms.Form
> >
> > #Region " Code généré par le Concepteur Windows Form "
> >
> > Public Sub New()
> > MyBase.New()
> >
> > 'Cet appel est requis par le Concepteur Windows Form.
> > InitializeComponent()
> >
> > 'Ajoutez une initialisation quelconque après l'appel
> > InitializeComponent()
> >
> > End Sub
> >
> > 'La méthode substituée Dispose du formulaire pour nettoyer la liste des
> > composants.
> > Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
> > If disposing Then
> > If Not (components Is Nothing) Then
> > components.Dispose()
> > End If
> > End If
> > MyBase.Dispose(disposing)
> > End Sub
> >
> > 'Requis par le Concepteur Windows Form
> > Private components As System.ComponentModel.IContainer
> >
> > 'REMARQUE : la procédure suivante est requise par le Concepteur Windows
> > Form
> > 'Elle peut être modifiée en utilisant le Concepteur Windows Form.
> > 'Ne la modifiez pas en utilisant l'éditeur de code.
> > Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
> > <System.Diagnostics.DebuggerStepThrough()> Private Sub
> > InitializeComponent()
> > Me.ComboBox1 = New System.Windows.Forms.ComboBox
> > Me.SuspendLayout()
> > '
> > 'ComboBox1
> > '
> > Me.ComboBox1.Location = New System.Drawing.Point(104, 48)
> > Me.ComboBox1.Name = "ComboBox1"
> > Me.ComboBox1.Size = New System.Drawing.Size(128, 21)
> > Me.ComboBox1.TabIndex = 0
> > Me.ComboBox1.Text = "ComboBox1"
> > '
> > 'Form1
> > '
> > Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
> > Me.ClientSize = New System.Drawing.Size(292, 266)
> > Me.Controls.Add(Me.ComboBox1)
> > Me.Name = "Form1"
> > Me.Text = "Form1"
> > Me.ResumeLayout(False)
> >
> > End Sub
> >
> > #End Region
> >
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > Dim conn As New OleDbConnection
> >
> > conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> > Source=E:DOTNETVBExemplestock.mdb;"
> > conn.Open()
> > Dim cmd As New OleDbCommand
> > cmd = New OleDbCommand
> > cmd.CommandText = "select * from Article"
> > Dim dr As OleDbDataReader
> > dr = cmd.ExecuteReader()
> > While dr.Read()
> > MsgBox(dr(0))
> > MsgBox(dr(1))
> > MsgBox(dr(2))
> > ' loading data into TextBoxes by column index
> > End While
> >
> >
> > End Sub
> > End Class
> >