本文整理汇总了C#中DataSet类的典型用法代码示例。如果您正苦于以下问题:C#DataSet类的具体用法?C#DataSet怎么用?C#DataSet使用的例子?这里精选的类代码示例或许可以为您提供帮助。
示例1:GetSmtpSettings
publicDataSetGetSmtpSettings()
{
DataSetdsSmtp=newDataSet();
SqlConnectionSqlCon=newSqlConnection(ConStr);
try
{
SqlCommandsqlCmd=newSqlCommand();
sqlCmd.Connection=SqlCon;
sqlCmd.CommandText="sp_Get_SmtpSettings";
sqlCmd.CommandType=CommandType.StoredProcedure;
SqlDataAdaptersqlDa=newSqlDataAdapter(sqlCmd);
sqlDa.Fill(dsSmtp);
}
catch(SqlExceptionSqlEx)
{
objNLog.Error("SQLException:"+SqlEx.Message);
thrownewException("Exceptionre-RaisedfromDLwithSQLError#"+SqlEx.Number+"whileInsertingSMTPSettings.",SqlEx);
}
catch(Exceptionex)
{
objNLog.Error("Exception:"+ex.Message);
thrownewException("**ErroroccuredwhileInsertingSMTPSettings.",ex);
}
finally
{
SqlCon.Close();
}
returndsSmtp;
}
原文链接:
http://www.jxszl.com/biancheng/C/556882.html