i'm developing a program for a cachier using c#. The program using ms access for the database. for somehow, the database does not enterd into the table. where is my problem? here is the code:
private void buttonCloseCart_Click(object sender, EventArgs e)
{
connect.ConnectionString = connString;
connect.Open();
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO ReceiptItem (ItemID, Quantity, UnitPrice) VALUES (#itemID, #temp_item_quantity, #temp_item_price)", connect);
cmd1.Parameters.Add("#temp_item", OleDbType.Char, 20);
cmd1.Parameters.Add("#temp_item_quantity", OleDbType.Integer, 20);
cmd1.Parameters.Add("#temp_item_price", OleDbType.Double, 20);
cmd1.Parameters.Add("#cart_sum", OleDbType.Double, 20);
cmd1.Parameters.Add("#itemID", OleDbType.Integer, 20);
for (int i = 0; i < baught_items.Count; i++)
{
/*Set temporary reference to the objects located on the List*/
string temp_item = baught_items[i].ToString();
int temp_item_quantity = baught_items_quantity[i];
double temp_item_price = baught_items_price[i];
double temp_total_item_price = total_items_price[i];
/*Set the connection to the CachierPro DataBase*/
OleDbConnection myconnection = new OleDbConnection(connect.ConnectionString);
myconnection.Open();
//OleDbConnection myconnection1 = new OleDbConnection(connect.ConnectionString);
//myconnection1.Open();
/*********************************************/
/*This Action get the Item Name directly from the database according to the item name in the cart*/
//OleDbConnection dataConnection = new OleDbConnection();
//dataConnection.ConnectionString = connString;
//dataConnection.Open();
//OleDbConnection oledbConn = new OleDbConnection(connString);
//oledbConn.Open();
//OleDbCommand myCommand1 = new OleDbCommand();
//myCommand1.Connection = myconnection1;
//myCommand1.Connection.Close();
OleDbCommand cmd = new OleDbCommand("SELECT [ItemID] FROM ItemsList WHERE [ItemName] = " + "'"+temp_item +"'" , connect);
OleDbDataReader dataReader = cmd.ExecuteReader();
if (dataReader.Read()) { }
int itemID = dataReader.GetInt32(0);
/********************************************/
/*Initialize the Command ment for the Query*/
OleDbCommand myCommand = new OleDbCommand();
myCommand.Connection = myconnection;
//myCommand.ExecuteNonQuery();
myCommand.Connection.Close();
//dataConnection.Close();
//oledbConn.Close();
myconnection.Close();
dataReader.Close();
/*Enter the first query*/
if (connect.State == ConnectionState.Open)
{
try
{ int addedCount = cmd.ExecuteNonQuery(); }
catch (Exception expe)
{ MessageBox.Show(expe.Message); connect.Close(); }
}
else
{
MessageBox.Show("Connection Failed");
}
}
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = new OleDbCommand("SELECT * FROM ReceiptItem", connect);
DataTable dt = new DataTable();
da.Fill(dt);
textBoxCurrentCartSumTXT.Clear();
textBoxPricePerOneTXT.Clear();
textBoxQuantityTXT.Clear();
textBoxSumForCurrentItemTXT.Clear();
connect.Close();
}
Items
ItemId
Item Name
Item Price
Recipet
ReciptID
ReciptInvoiceNo
ReciptDateTime
ReciptItem
ReciptID
ItemID
Quantity
UnitPrice
Related
string connstr = "connstr";
SqlConnection connection = new SqlConnection(#"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Application Name=Aung");
connection.Open();
SqlCommand cmdCount = new SqlCommand("SELECT COUNT(*) FROM Mini_table WHERE Item = #Item", connection);
cmdCount.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
int count = (int)cmdCount.ExecuteScalar();
int i = 0;
if (count > 0)
{
SqlCommand command = new SqlCommand("SELECT Qty FROM Mini_table WHERE Item = #Item", connection);
command.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
i = Convert.ToInt32(reader["Qty"]);
}
}
SqlCommand updatecmd = new SqlCommand("Update Mini_table set Qty=#Qty, Date=#Date where Item=#Item", connection);
updatecmd.Parameters.AddWithValue("#Qty", i + Nd2.Value);
updatecmd.Parameters.AddWithValue("#Date", DateTime.Now);
updatecmd.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
updatecmd.ExecuteNonQuery();
dgv2.DataSource = null;
MessageBox.Show("Update successfully");
}
else
{
SqlCommand insertcmd = new SqlCommand("insert into Mini_table(Item,Qty,Date)values(#Item,#Qty,#Date)", connection);
insertcmd.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
insertcmd.Parameters.AddWithValue("#Qty", Nd2.Value);
insertcmd.Parameters.AddWithValue("#Date", DateTime.Now);
insertcmd.ExecuteNonQuery();
dgv2.DataSource = null;
MessageBox.Show("Insert successfully");
}
connection.Close();
}
{
string connstr = "connstr";
SqlConnection connection = new SqlConnection(#"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=master;Integrated Security=True;Application Name=Aung");
connection.Open();
SqlCommand cmdCount = new SqlCommand("SELECT COUNT(*) FROM Stotal_table WHERE Item = #Item", connection);
cmdCount.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
int count = (int)cmdCount.ExecuteScalar();
int i = 0;
if (count > 0)
{
SqlCommand command = new SqlCommand("SELECT MiniBar FROM Stotal_table WHERE Item = #Item", connection);
command.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
i = Convert.ToInt32(reader["MiniBar"]);
{
}
}
}
SqlCommand updatecmd = new SqlCommand("Update Stotal_table set MiniBar=#MiniBar, where Item=#Item", connection);
updatecmd.Parameters.AddWithValue("#MiniBar", i + Nd2.Value);
updatecmd.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
updatecmd.ExecuteNonQuery();
}
else
{
SqlCommand insertcmd = new SqlCommand("insert into Stotal_table(Item,MiniBar)values(#Item,#MiniBar)", connection);
insertcmd.Parameters.AddWithValue("#Item", cbox2.SelectedItem.ToString());
insertcmd.Parameters.AddWithValue("#MiniBar", Nd2.Value);
insertcmd.ExecuteNonQuery();
}
connection.Close();
Before assigning the reader value to int, first check if the reader object is DBNull
for example
if (reader["MiniBar"] != DBNull.Value)
{
i = Convert.ToInt32(reader["MiniBar"]);
}
else
{
i = 0; // or -1
}
I've got the following code:
private void btnAddMatter_Click(object sender, EventArgs e)
{
MatterCode = "";
EntityID = 0;
FeeEarnerID = 0;
OpenedByUserID = 0;
CompanyContactDetailsID = 0;
Description = "";
OurReference = "";
TheirReference = "";
DateOpened = DateTime.Now;
MatterTypeID = 0;
DepartmentID = 0;
ResponsibleUserID = 0;
TrustBankAccountID = 0;
BusinessBankAccountID = 0;
string connectionString = "Data Source=***\\SQLEXPRESS;Initial Catalog=STUPELG;Persist Security Info=True;User ID=***;Password=***";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("INSERT INTO dbo.Matter ( MatterCode, EntityID, FeeEarnerID, OpenedByUserID, CompanyContactDetailsID, Description," +
" OurReference, TheirReference, DateOpened, MatterTypeID, DepartmentID, ResponsibleUserID, TrustBankAccountID, BusinessBankAccountID)" +
" VALUES ( #MatterCode, #EntityID, #FeeEarnerID, #OpenedByUserID, #CompanyContactDetailsID, #Description," +
" #OurReference, #TheirReference, #DateOpened, #MatterTypeID, #DepartmentID, #ResponsibleUserID, #TrustBankAccountID, #BusinessBankAccountID);" +
" SELECT SCOPE_IDENTITY();");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("#MatterID", MatterID);
cmd.Parameters.AddWithValue("#MatterCode", MatterCode);
cmd.Parameters.AddWithValue("#EntityID", EntityID);
cmd.Parameters.AddWithValue("#FeeEarnerID", FeeEarnerID);
cmd.Parameters.AddWithValue("#OpenedByUserID", OpenedByUserID);
cmd.Parameters.AddWithValue("#CompanyContactDetailsID", CompanyContactDetailsID);
cmd.Parameters.AddWithValue("#Description", Description);
cmd.Parameters.AddWithValue("#OurReference", OurReference);
cmd.Parameters.AddWithValue("#TheirReference", TheirReference);
cmd.Parameters.AddWithValue("#MatterTypeID", MatterTypeID);
cmd.Parameters.AddWithValue("#DepartmentID", DepartmentID);
cmd.Parameters.AddWithValue("#ResponsibleUserID", ResponsibleUserID);
cmd.Parameters.AddWithValue("#TrustBankAccountID", TrustBankAccountID);
cmd.Parameters.AddWithValue("#BusinessBankAccountID", BusinessBankAccountID);
cmd.Parameters.AddWithValue("#DateOpened", DateOpened);
connection.Open();
cmd.ExecuteNonQuery();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet NewMatterID = new DataSet();
adapter.Fill(NewMatterID);
MatterCode = Convert.ToString(NewMatterID.Tables[0].Rows[0][0]);
}
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand("UPDATE Matter SET MatterCode = #MatterCode WHERE MatterID = " + MatterCode);
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
cmd.Parameters.AddWithValue("#MatterCode", MatterCode);
connection.Open();
cmd.ExecuteNonQuery();
}
MessageBox.Show("Matter " + MatterCode + " successfully created");
}
After the row is inserted, the new MatterID (primary key that is generated automatically) should be copied to the MatterCode field. Currently it works EXCEPT that there is an extra row that is generated at when the button is clicked:
How do I fix this???
Well - this is because your code is executing the INSERT query twice......
connection.Open();
cmd.ExecuteNonQuery(); // first execution
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet NewMatterID = new DataSet();
adapter.Fill(NewMatterID); // second execution
I'm not entirely sure what you wanted to do with that SqlDataAdapter - but it's using the same SqlCommand from before, with the INSERT statement, which gets executed a second time......
You can replace this:
cmd.ExecuteNonQuery();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet NewMatterID = new DataSet();
adapter.Fill(NewMatterID);
MatterCode = Convert.ToString(NewMatterID.Tables[0].Rows[0][0]);
with
MatterCode = cmd.ExecuteScalar().ToString();
as ExecuteScalar runs the command and returns the value of the first column of the first row of the first resultset.
this combo box gets the job id from the database and assigns it to the jobidcombobox.
private void filljobid()
{
SqlConnection con = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT job_id FROM job";
DataSet ds = new DataSet();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
dAdapter.Fill(ds);
con.Close();
jobidcombobox.DisplayMember = "job_id";
jobidcombobox.ValueMember = "job_id";
jobidcombobox.DataSource = ds.Tables[0];
}
And then this indexchange code takes the jobidcombobox value and uses it it to query to get the rest of the columns that relate to it.
private void jobidcombobox_SelectedIndexChanged(object sender, EventArgs e)
{
string JobID = jobidcombobox.Text;
SqlConnection con = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * from job where job_id = '" + JobID + "' ";
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
customeridcombobox.Text = ds.Tables[0].Rows[0]["customer_id"].ToString();
depotidcombobox.Text = ds.Tables[0].Rows[0]["depot_id"].ToString();
startlocationtextbox.Text = ds.Tables[0].Rows[0]["start_location"].ToString();
endlocationtextbox.Text = ds.Tables[0].Rows[0]["end_location"].ToString();
jobtypecombobox.Text = ds.Tables[0].Rows[0]["job_type"].ToString();
}
else
{
MessageBox.Show("Invalid job number");
}
}
As seen above the customerid is filled but only with a single value which relates to the jobid. I would like to add other customer id values in here from the database. I have tried to same function as jobid to get the customer id but i cant make it relate to the job id.
Is there any way to do this?
Try this...
Fill the job id and customer id boxes.
private void FillJobIdAndCustomerId()
{
SqlConnection con = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT job_id, customer_id FROM job";
DataSet ds = new DataSet();
SqlDataAdapter dAdapter = new SqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
dAdapter.Fill(ds);
con.Close();
var dataRows = ds.Tables[0].AsEnumerable();
jobidcombobox.DisplayMember = "job_id";
jobidcombobox.ValueMember = "job_id";
jobidcombobox.DataSource = dataRows.Select(x=>x.job_id);
customeridcombobox.DisplayMember = "customer_id";
customeridcombobox.ValueMember = "customer_id";
customeridcombobox.DataSource = dataRows.Select(x=>x.customer_id);
}
And then when the a job id is selected...
private void jobidcombobox_SelectedIndexChanged(object sender, EventArgs e)
{
string JobID = jobidcombobox.Text;
SqlConnection con = new SqlConnection(strConn);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "SELECT * from job where job_id = #jobId";
commandObject.Parameters.AddWithValue("#jobId", JobID);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
customeridcombobox.SelectedIndex = customeridcombobox.FindString(ds.Tables[0].Rows[0]["customer_id"].ToString());
depotidcombobox.Text = ds.Tables[0].Rows[0]["depot_id"].ToString();
startlocationtextbox.Text = ds.Tables[0].Rows[0]["start_location"].ToString();
endlocationtextbox.Text = ds.Tables[0].Rows[0]["end_location"].ToString();
jobtypecombobox.Text = ds.Tables[0].Rows[0]["job_type"].ToString();
}
else
{
MessageBox.Show("Invalid job number");
}
}
Can follow similar pattern for other combo boxes you have (dept, jobtype from your example) if you would like to.
Note: You may have observed that I changed the query building slightly, using SqlParameters. The way it was written in your sample code is a classic case of SQL Injection.
am trying to get the selected item from the database, but its not displaying nothing
code behind:
private void bindRows()
{
try
{
string connectionString = ConfigurationManager.ConnectionStrings["MainConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlCommand cmd = new SqlCommand("select id, message from Dropdown", connection);
SqlDataReader reader = cmd.ExecuteReader();
reader.Close();
SqlDataAdapter adapter = new SqlDataAdapter("select id, message from Dropdown", connection);
DataSet ds = new DataSet();
adapter.Fill(ds);
DdlRegister.DataSource = ds;
DdlRegister.DataTextField = "message";
DdlRegister.DataValueField = "id";
DdlRegister.DataBind();
DdlRegister.Items.Insert(0, new ListItem("I Want", "0"));
connection.Close();
}
catch (Exception e)
{
}
}
code of buttonclick
try
{
string connectionString = ConfigurationManager.ConnectionStrings["MainConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
string selectCommand = "Insert into Register (name,designation,company,mobile,email,message) values(#name,#designation,#company,#mobile,#email,#message);";
SqlCommand cmd = new SqlCommand(selectCommand, connection);
cmd.Parameters.AddWithValue("#name", txtname.Text.Trim());
cmd.Parameters.AddWithValue("#designation", txtdesignation.Text.Trim());
cmd.Parameters.AddWithValue("#company", txtcompany.Text.Trim());
cmd.Parameters.AddWithValue("#mobile", txtmobile.Text.Trim());
cmd.Parameters.AddWithValue("#email", txtemail.Text.Trim());
cmd.Parameters.AddWithValue("#message", DdlRegister.SelectedItem.Text.Trim());
int cnt = cmd.ExecuteNonQuery();
if (cnt > 0)
{
ShowMessage("Registeration is done");
}
Response.Redirect("Index.aspx");
connection.Close();
}
catch (Exception ex)
{
}
design
<asp:DropDownList ID="DdlRegister" runat="server" CssClass="form-control ddl " OnSelectedIndexChanged="DdlRegister_SelectedIndexChanged" AutoPostBack="true" >
</asp:DropDownList>
private void bindRows()
{
try
{
string connectionString = ConfigurationManager.ConnectionStrings["MainConnectionString"].ConnectionString;
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter("select id, message from Dropdown", connection);
DataSet ds = new DataSet();
adapter.Fill(ds);
DdlRegister.DataSource = ds;
DdlRegister.DataTextField = "message";
DdlRegister.DataValueField = "id";
DdlRegister.DataBind();
DdlRegister.Items.Insert(0, new ListItem("I Want", "0"));
connection.Close();
}
catch (Exception e)
{
}
}
try something like this
string mainconn = ConfigurationManager.ConnectionStrings["MY"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
string sqlquery = "select * from [dbo].[sortcompany]";
SqlCommand sqlcomm = new SqlCommand(sqlquery, sqlconn);
sqlconn.Open();
SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);
DataTable dt = new DataTable();
sda.Fill(dt);
Company.ValueMember = "company_name";
Company.DisplayMember = "company_name";
Company.DataSource = dt;
How can i get the value of company_name from Comp table and store it on a comboBox?
here is my initial code on getting the values from Database and store it on a combobox:
string Sql = "select company_name from JO.dbo.Comp";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(Sql, conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
it point out to da.fill(ds) and says "Could not locate entry in sysdatabases for database 'select company_name from JO'. No entry found with that name. Make sure that the name is entered correctly."
hope for your reply thanks!
Use datareader it is much simpler \
string Sql = "select company_name from JO.dbo.Comp";
SqlConnection conn = new SqlConnection(connString);
conn.Open();
SqlCommand cmd = new SqlCommand(Sql, conn);
SqlDataReader DR = cmd.ExecuteReader();
while (DR.Read())
{
combobox1.Items.Add(DR[0]);
}
If you set up your connection string to be something of this sort:
string SqlConnectionString = "Data Source=[SERVER];Initial Catalog=[DATABASE];"
Then using that set up, you can set your string 'Sql' as:
string Sql = "select company_name from dbo.Comp";
This could be a possible set up you could use to read out the values.
using (SqlConnection saConn = new SqlConnection(this.ConnectionString))
{
saConn.Open();
string query = "select DBName from dbo.Company";
SqlCommand cmd = new SqlCommand(query, saConn);
using (SqlDataReader saReader = cmd.ExecuteReader())
{
while (saReader.Read())
{
string name = saReader.GetString(0);
combobox1.Add(name);
}
}
saConn.Close();
}
I would like to introduce you a very simple way to SQL data into a combobox as:
first you have a create a SQL table,
in C# platform drop a combobox and go to its property,
in the property menu click on "DataSource"
specify the database and table to load into combobox,
Note, the combobox name and table's row should be the same.
{
SqlConnection con =new SqlConnection("Data Source=Server_Name;Initial Catalog=Database_Name;integrated security=true");
SqlCommand cmd;
SqlDataReader dr;
private void CashMemoForm_Load(object sender, EventArgs e)
{
con.Open();
cmd = new SqlCommand("Select Column_Name From Table_Name", con);
dr = cmd.ExecuteReader();
while (dr.Read())
{
comboBox1.Items.Add(dr[0]).ToString();
}
}
}
Have you ever tried Entity Framework for database access and dto creation?
Change your line to cmd.CommandType = CommandType.Text; instead of cmd.CommandType = CommandType.StoredProcedure;
Try this
string Sql = "select Company_ID,company_name from JO.dbo.Comp";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(Sql, conn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
comboBox1.DataSource = ds.Tables[0];
comboBox1.DataTextField = "company_name";
comboBox1.DataValueField = "Company_ID";
comboBox1.DataBind();
comboBox1.Items.Insert(0, new ListItem("--Select--", "0"));
}
There is no use of for loop. you just need to check that whether the dataset contains rows or not.
string Sql = "select Company_ID,company_name from JO.dbo.Comp";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(Sql, conn);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
comboBox1.DataSource = ds.Tables[0];
comboBox1.DataTextField = "company_name";
comboBox1.DataValueField = "Company_ID";
comboBox1.DataBind();
comboBox1.Items.Insert(0, new ListItem("Select", "0"));
}
string Sql = "select company_name from JO.dbo.Comp";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(Sql, conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
comboBox1.Items.Add(ds.Tables[0].Rows[i][0].ToString());
public System.Data.DataTable EmployeeViewAll()
{
DataTable dtbl = new DataTable();
try
{
// Here it shuld be your database Connection String
string connectionString = "Server = .; database = HKS; Integrated Security = true";
using (SqlConnection sqlCon = new System.Data.SqlClient.SqlConnection(connectionString))
{
SqlDataAdapter SqlDa = new SqlDataAdapter("employeeViewAll", sqlCon);
SqlDa.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlDa.Fill(dtbl);
}
return dtbl;
}
catch (Exception)
{
throw;
}
}
public void ComboFill()
{
DataTable dt = new DataTable();
eSP SP = new eSP();
d = SP.EmployeeViewAll();
comboBox1.DataSource = dt;
comboBox1.DisplayMember = "department";
comboBox1.ValueMember = "empName";
}