//you will need the my previous post . which i have explained about the DC Connection..
// I will call tht function and and connect the database;
// http://easycodestuff.blogspot.com/2013/11/c-sql-server-2008-database-connection.html
public void setSPCombo() //ComboBox Load Functions
{
DBConnection connection = new DBConnection();//make a object from the class DB Connection
SqlConnection con = connection.ConnectDB();
SqlCommand command = con.CreateCommand(); //creates a command with connection
command.CommandText = "SELECT ColumnName From TableName ORDER BY (ColumnName)";
//use order by if u want to order it in a-z format or 1-9 formats.
SqlDataReader reader = command.ExecuteReader(); // u have to execute through a reader..
comboname.Items.Clear(); //Fist clear the combobox because we dont want old the values
comboname.Items.Add("Select"); //write a default vale and set it .
comboname.SelectedIndex = 0;
while (reader.Read())//read until the end of reader and add all the result rows to the combo
{
comboname.Items.Add(reader[0].ToString());
}
reader.Close(); // close the reader and con..we dont wont trouble later
con.Close();
}
Subscribe to:
Post Comments (Atom)
JWT Token Decode Using Jquery
When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...
-
In this blog post Ill explain you the logic behind the Sri Lankan National Identity Card (NIC). Sri Lanka now has Old NIC No Format as well ...
-
In This Article I Will Demonstrate You To Create A Simple Chat Program Using Java Remote Method Invocation(RMI). Following Program Supports ...
-
In a windows form application sometimes you may want to import a excel file to a data grid view. In this blog post Ill demonstrate to you gu...
No comments:
Post a Comment