Bonjour Excusé moi de vous déranger ce matin voila j'ai crée un projet de gestion des notes des élèves avec VB.net et SQL server je voudrais donc maintenant crée des rapport avec Crystal Report pour visual studio lorsque je lance la géneration du rapport une erreur saffiche<< (Une exception non gérée du type 'System.Runtime.InteropServices.COMException' s'est produite dans CrystalDecisions.CrystalReports.Engine.dll
Informations supplémentaires : Index non valide. (Exception de HRESULT : 0x8002000B (DISP_E_BADINDEX)))>> aider mois si vous avez une idé merci
j'ai tou dabod créé un modul pour la connexion à mon server et aussi definir d'autre paamètres
et voila le code de la section de la table depuis sql server qui mache bien j'usqu'au moment ou je clic sur le bouton Affiché le raport
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 Imports System.Data.SqlClient Module Procedure Public con As New SqlConnection Public cmd As New SqlCommand Public da As New SqlDataAdapter Public ds As New DataSet Public dt As New DataTable Public bs As New BindingSource Public dr As SqlDataReader Public i As Integer Public a As New OpenFileDialog Public Sub connecter() 'con.ConnectionString = "Data Source=DESKTOP-1GU82T3;Initial Catalog=LARIVE;Integrated Security=True" con.ConnectionString = "Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" & Application.StartupPath & "\LARIVE.mdf;Integrated Security=True" con.Open() End Sub Public Sub deconnecter() con.Close() End Sub Public Sub RemplirGrid(dg As DataGridView, table As String) If Not ds.Tables("DT" & table) Is Nothing Then ds.Tables("DT" & table).Clear() End If Call connecter() cmd.CommandText = "SELECT * FROM " & table cmd.Connection = con da.SelectCommand = cmd da.Fill(ds, "DT" & table) dg.DataSource = ds.Tables("DT" & table) Call deconnecter() End Sub Public Sub ViderForm(f As Control) For Each ctl As Control In f.Controls If TypeOf ctl Is TextBox Then ctl.Text = "" End If If TypeOf ctl Is DateTimePicker Then CType(ctl, DateTimePicker).Value = Now End If If TypeOf ctl Is ComboBox Then CType(ctl, ComboBox).Text = "" End If If TypeOf ctl Is PictureBox Then CType(ctl, PictureBox).Image = Nothing End If If TypeOf ctl Is GroupBox Or TypeOf ctl Is Panel Then For Each ctl2 As Control In ctl.Controls If TypeOf ctl2 Is RadioButton Then CType(ctl2, RadioButton).Checked = False End If If TypeOf ctl2 Is CheckBox Then CType(ctl2, CheckBox).Checked = False End If Next End If Next End Sub End Module
lorsque l'erreur se produit la flèche est pointé vers la ligne suivante <<r.SetParameterValue(0, c1.Text)>>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load con.Open() cmd.Connection = con ChargerNotesElève() End Sub Sub ChargerNotesElève() cmd.CommandText = "SELECT Code_Elève,Nom_Prenom FROM Elèves_Par_Classe" dr = cmd.ExecuteReader bs.DataSource = dr c1.DataSource = bs c1.DisplayMember = "Nom_Prenom" c1.ValueMember = "Code_Elève" dr.Close() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim r As New Fiche r.SetParameterValue(0, c1.Text) CrystalReportViewer1.ReportSource = r End Sub? l'ereur se poduit sur la ligne <<r.SetParameterValue(0, c1.Text)>>
je voudrais aussi précise que la table selectionnée est lié à une autre table Nomme Notes_par_Matière par la contrainte de cle primaire Code_Elève et les deux tables sont selectionnés dans CRystal Report. je suis bloqué et je vous prie à cet effet de maider.
Partager