TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Keith Gardner
NA
1
15.8k
Storing SQL Select Results into Variable
Feb 7 2011 2:51 PM
I have a SQL Connection setup to select ID, Model and Family. The Model and ID are stored into a Dropdownlist. I want to store the Family which is an INT into a variable that can be referenced later. I can't seem to figure out how to store the single value of FAMILY into a variable.
using (SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Database"].ToString()))
{
using (SqlCommand myCmd = new SqlCommand())
{
myConn.Open();
myCmd.Connection = myConn;
myCmd.CommandText = "SELECT ID, MODEL, FAMILY FROM Table ORDER BY SORT_ORDER ASC";
myCmd.CommandType = System.Data.CommandType.Text;
using (SqlDataReader myReader = myCmd.ExecuteReader())
{
DropDownListRemote.DataSource = myReader;
DropDownListRemote.DataTextField = "MODEL";
DropDownListRemote.DataValueField = "ID";
DropDownListRemote.DataBind();
DropDownListRemote.Items.Insert(0, new ListItem("--Select a Model--", "0"));
DropDownListRemote.SelectedIndex = 0;
}
}
}
Reply
Answers (
2
)
Enable/Disable Cells of Datagridview On ComboboxColumn's selectedIndexChanged Event
sum of datagridview values