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 WindowsFormsApplication1
{
public partial class Order : Form
{
public int count = 0;
public string Conn = WindowsFormsApplication1.conn.getConnection();
public string getid;
public SqlDataAdapter dAdapter, dAdapter1;
public DataSet dSet, dSet1;
public SqlDataReader reader, reader1, reader2, myReader;
public int id, i;
public string mode;
public Order()
{
InitializeComponent();
}
private void Order_Load(object sender, EventArgs e)
{
SqlConnection myConnection_Company = new SqlConnection(Conn);
myConnection_Company.Open();
string load_company = "SELECT Customer_ID, Company_Name, Email FROM tbl_customer";
SqlCommand cmd_company = new SqlCommand(load_company, myConnection_Company);
SqlDataAdapter adapter_company = new SqlDataAdapter();
DataSet ds_company = new DataSet();
adapter_company.SelectCommand = cmd_company;
adapter_company.Fill(ds_company);
tb_Company.DataSource = ds_company.Tables[0];
tb_Company.ValueMember = "Customer_ID";
tb_Company.DisplayMember = "Company_Name";
tb_email.Text = ds_company.Tables["tbl_Customer"].Rows[0]["Email"].ToString();
reader = cmd_company.ExecuteReader();
myConnection_Company.Close();
}
private void tb_Company_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection myConnection_Company = new SqlConnection(Conn);
myConnection_Company.Open();
SqlDataAdapter adapter_company = new SqlDataAdapter("select * from tbl_Customer where Customer_ID='" + tb_Company.SelectedItem.ToString() + "'", myConnection_Company);
DataSet ds_company = new DataSet();
adapter_company.Fill(ds_company);
if (ds_company.Tables["tbl_Customer"].Rows.Count > 0)
{
tb_email.Text = ds_company.Tables["tbl_Customer"].Rows[0]["Email"].ToString();
}
else
{
tb_email.Text = "";
}
myConnection_Company.Close();
}
}
}
im also having this error message
---- object reference is not set to an instance
when i run this code
any help is very much appreciated :) thanks guys...