Click here to Skip to main content
13,295,953 members (52,194 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 9:40am
Updated 12-Oct-12 11:15am
Wes Aday 12-Oct-12 14:46pm
okay..... what is it that you think "invenrep" is? You have not declared it.
Sergey Alexandrovich Kryukov 12-Oct-12 14:58pm
It must mean "invent_repeatedly", or "invention_repetition_number"... :-)
Wes Aday 12-Oct-12 15:00pm
He copied the code from an incomplete answer to someone else from 2 years ago.
Sergey Alexandrovich Kryukov 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100