DataTable tblSchemaDtaTbl = new DataTable();
#region Get table schema
try
{
using (SqlConnection sqlCn = new SqlConnection(sqlCnStr))
{
sqlCn.Open();
string sqlCmdStr = String.Format("SELECT * FROM {0}", tblName);
SqlCommand sqlCmd = new SqlCommand(sqlCmdStr, sqlCn);
SqlDataReader sqlDtaRdr = sqlCmd.ExecuteReader();
tblSchemaDtaTbl = sqlDtaRdr.GetSchemaTable();
sqlDtaRdr.Close();
}
}
catch (Exception ex)
{
MessageBox.Show( ex.Message, "Error!" );
}
#endregion
No comments:
Post a Comment