Wednesday, March 21, 2012

Row of Table, to a Variable

I'm a new member of forum,
I'm a Brazilian, and don't speak english very good...
But, i need help...
private void Page_Load(object sender, System.EventArgs e)
{
string ConnectionString = "server=Server;database=db;userid=XXX;pwd=YYY";
string CommandText = "SELECT * FROM usuario";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlCommand myCommand = new SqlCommand(CommandText, myConnection);
myConnection.Open();
dgrid.DataSource =myCommand.ExecuteReader(CommandBehavior.CloseConnection);
dgrid.DataBind();
}

I'm want pass a value of database table to a variable, how to make it ?
You could look at datasets instead of readers
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataSetClassTopic.asp?frame=true

No comments:

Post a Comment