本文整理汇总了C#中SqlServer.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqlServer.ExecuteNonQuery方法的具体用法?C# SqlServer.ExecuteNonQuery怎么用?C# SqlServer.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlServer
的用法示例。
在下文中一共展示了SqlServer.ExecuteNonQuery方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogError
//.........这里部分代码省略.........
try { FullErrorText += WriteValue(o.ToString() +": "+ HttpContext.Current.Request.QueryString[o.ToString()]); }
catch (Exception ex2) { FullErrorText += WriteValue("Not able to read Query string element due to exception: " + ex2.ToString()); }
}
FullErrorText += WriteHeading("Form");
foreach (object o in HttpContext.Current.Request.Form)
{
try { FullErrorText += WriteValue(o.ToString() + ": " + HttpContext.Current.Request.Form[o.ToString()]); }
catch (Exception ex2) { FullErrorText += WriteValue("Not able to read Form element due to exception: " + ex2.ToString()); }
}
if (_storage == StorageType.Access)
{
strSQL = " INSERT INTO [Errors]";
strSQL += " ( Message, ";
strSQL += " Page, ";
strSQL += " FullErrorText, ";
strSQL += " ErrorDate )";
strSQL += " VALUES ( ?Message, ";
strSQL += " ?Page, ";
strSQL += " ?FullErrorText, ";
strSQL += " ?ErrorDate ) ";
using (conn = new MySqlConnection(_dsn))
{
using (mysql = new MySqlCommand(strSQL, conn))
{
mysql.Parameters.Add("?Message", MySqlDbType.VarChar, 250).Value = "SendMail";
mysql.Parameters.Add("?Page", MySqlDbType.VarChar, 500).Value = "SendMail";
mysql.Parameters.Add("?FullErrorText", MySqlDbType.VarChar, 500).Value = FullErrorText;
mysql.Parameters.Add("?ErrorDate", MySqlDbType.DateTime).Value = DateTime.Now;
conn.Open();
mysql.ExecuteNonQuery();
}
}
}
else if (_storage == StorageType.SQLServer)
{
strSQL = @" INSERT INTO [Errors]
(Message,
Page,
FullErrorText,
ErrorDate )
VALUES (@Message,
@Page,
@FullErrorText,
@ErrorDate ) ";
sql = new SqlServer();
p = new IDataParameter[4];
p[0] = sql.GetParameter("@Message", "SendMail");
p[1] = sql.GetParameter("@Page", "SendMail");
p[2] = sql.GetParameter("@FullErrorText", FullErrorText);
p[3] = sql.GetParameter("@ErrorDate", DateTime.Now.ToString());
sql.ExecuteNonQuery(_dsn, System.Data.CommandType.Text, strSQL, p);
}
else if (_storage == StorageType.MySQL)
{
try
{
strSQL = @"INSERT INTO errors
(ID,
Message,
Page,
FullErrorText,