using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Data.SqlClient;
using System.Windows.Forms;
public class SqlDataAccess
{
private static string ConnectionString = "Data Source=...; Initial Catalog=...; UID=...";
public static void selectFromTable(string TableName)
{
try
{
using (SqlConnection sqlConnection = new SqlConnection(ConnectionString))
{
sqlConnection.Open();
using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
{
string sqlTxt = "select * from " + TableName; //твой запрос
sqlCommand.CommandText = sqlTxt;
sqlCommand.CommandType = CommandType.Text;
sqlCommand.ExecuteNonQuery();
}
sqlConnection.Close();
}
}
catch (Exception err)
{
MessageBox("Error");
}
}