Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#
I have a problem in this code i want to Transfer the datas from DataGridView To Crystal Report
but have an error can anybody help me ???
this is my code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace test
    public partial class Form1 : Form
        public Form1()
        DB db = new DB();
        DataSet ds;
        private void button1_Click(object sender, EventArgs e)
            ds = db.ExecuteDataset(CommandType.StoredProcedure, "sp_user_list", "T", new SqlParameter[]
                 new SqlParameter("@sex",comboBox1.Text)
            dataGridView1.DataSource = ds.Tables["T"];
            dataGridView1.Columns[0].HeaderText = "کد کاربر";
            dataGridView1.Columns[1].HeaderText = "نام";
            dataGridView1.Columns[2].HeaderText = "نام خانوادگی";
            dataGridView1.Columns[3].HeaderText = "جنسیت";
            dataGridView1.Columns[4].HeaderText = "تلفن";
            dataGridView1.Columns[5].HeaderText = "آدرس";
        private void button2_Click(object sender, EventArgs e)
           crystalReportViewer1.Enabled = true;
           DataTable dt = new DataTable();
           dt = dataGridView1.DataSource as DataTable;
           //error is in this line . it say the invenrep does not exist.
           crystalReportViewer1.ReportSource = invenrep;//this line too            
how resolve this problem . what format must be define for " invenrep"???
Posted 12-Oct-12 8:40am
Edited 12-Oct-12 10:15am
Wes Aday at 12-Oct-12 14:46pm
okay..... what is it that you think "invenrep" is? You have not declared it.
Sergey Alexandrovich Kryukov at 12-Oct-12 14:58pm
It must mean "invent_repeatedly", or "invention_repetition_number"... :-)
Wes Aday at 12-Oct-12 15:00pm
He copied the code from an incomplete answer to someone else from 2 years ago.
Sergey Alexandrovich Kryukov at 12-Oct-12 15:11pm
Aha! And what kind of punishment is in order, in such cases? Where is the CodeProject "Malleus Maleficarum", I forgot? :-)
(For those who in a tank :-), I refer to 3-rd part of this:

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

it is giving error that invenrep does not exist because you can't declare that in your code.
so please declare invenrepand than try to run your code.
i think your code is incomplete.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 405
1 Sergey Alexandrovich Kryukov 220
2 Peter Leow 215
3 Maciej Los 195
4 DamithSL 174

Advertise | Privacy | Mobile
Web01 | 2.8.140709.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid