Im using VS 2010. I have a form with a textbox and reportviewer on it.
In my form textbox client inserts a value name Invoicenumber then when user press button the reportviewer must generate and in reportviewer textbox i want invoice number to display.
I created a parameter for invoicenumber: Parameter!invoicenumber and called it in my reportviewer expression. What am i missing
This is my Form 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;
using System.Windows.Forms.PropertyGridInternal;
namespace WindowsFormsApplication1
{
public partial class Form12 : Form
{
string ConnectionString = @"Data Source=Admin-PC\SQLEXPRESS;Initial Catalog=Couriers;Integrated Security=True";
SqlCommand com;
String str;
DataTable dt;
public Form12()
{
InitializeComponent();
}
private void Form12_Load(object sender, EventArgs e)
{
this.cycleTableAdapter.Fill(this.couriersDataSet20.Cycle);
SqlConnection sqlConn = new SqlConnection(ConnectionString);
sqlConn.Open();
str = "SELECT * from Cycle";
SqlCommand com = new SqlCommand(str, sqlConn);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds, "Cycle");
dt = ds.Tables["Cycle"];
sqlConn.Close();
comboBox1.DataSource = ds.Tables["Cycle"];
comboBox1.DisplayMember = "CycleNumber";
comboBox1.Text = "select";
textBox3.Text =
textBox4.Text = "";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
this.WaybillsTableAdapter.Fill(this.DataSet1.Waybills, textBox1.Text, textBox3.Text, textBox4.Text);
Random random = new Random();
int num = random.Next(1, 10000);
textBox2.Text= Convert.ToString(num);
new Microsoft.Reporting.WinForms.ReportParameter("invoicenumber", textBox2.Text);
this.reportViewer1.RefreshReport();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection sqlConn = new SqlConnection(@"Data Source=Admin-PC\SQLEXPRESS;Initial Catalog=Couriers;Integrated Security=True");
sqlConn.Open();
str = "SELECT * from Cycle where CycleNumber='" + comboBox1.Text.Trim() + "'";
com = new SqlCommand(str, sqlConn);
SqlDataReader reader = com.ExecuteReader();
if (reader.Read())
{
textBox3.Text = reader["StartDate"].ToString();
textBox4.Text = reader["EndDate"].ToString();
}
sqlConn.Close();
reader.Close();
}
private void label4_Click(object sender, EventArgs e)
{
Random random = new Random();
int num = random.Next(1, 10000);
label4.Text = Convert.ToString(num);
}
}
}
As u see my textbox 2 generates a random number that i want to use as invoice number.
But now the problem is im not sure how to display textbox2 input into my reportviewer