Posted by: ayhan | 27/04/2011

C# Basit bir sql connection ile data çekmek

SqlConnection con = new SqlConnection();
con.ConnectionString = “Data Source=server;Initial Catalog=databasename;User ID=sql_user_name; Password=sql_user_password MultipleActiveResultSets=True”;

try
{
con.Open();
SqlDataAdapter dataAdapter = new SqlDataAdapter(“SELECT * FROM TableName (NOLOCK)”, con);
DataTable dataTable = new DataTable();
dataAdapter.Fill(dataTable);
}
catch (Exception exception)
{
//
}
finally
{
con.Close();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: