Over a million developers have joined DZone.

C#: Execute A Query & Return A Reader

·

public static SqlDataReader GetReader(string Query)
{
	string ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["CONNECTION_STRING_NAME"].ConnectionString;
	SqlConnection con = new SqlConnection(ConnectionString);
	SqlCommand command = new SqlCommand();

	command.Connection = con;
	command.Connection.Open();
	command.CommandText = Query;
	return command.ExecuteReader();
}
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}