Hi can anyone see what the problem is below
I am new to c# so not sure why this code does not excute?
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 Eight_Stage
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnClick_Click(object sender, EventArgs e)
{
string connectionString = null;
SqlConnection sqlCnn;
SqlCommand sqlCmd;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds = new DataSet();
int i = 0;
string sql = null;
connectionString = "Data Source=GGG-RRR-REP1;Initial Catalog=Reporting;User Id=user; Password=password;connect Timeout=0";
sql = "Select Distinct PCode,Emails,Comments,Send_Option from [GGG-RRR-rep1].Reporting.dbo.myTable";
sqlCnn = new SqlConnection(connectionString);
try
{
sqlCmd = new SqlCommand(sql, sqlCnn);
dgEmail.DataSource = ds;
sqlCnn.Open();
adapter.Fill(ds);
adapter.Dispose();
sqlCmd.Dispose();
sqlCnn.Close();
}
catch (Exception ex )
{
MessageBox.Show("Error ! "+ ex.Message);
}
}
}
}