本文整理汇总了C#中Database.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# Database.ExecuteNonQuery方法的具体用法?C# Database.ExecuteNonQuery怎么用?C# Database.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Database
的用法示例。
在下文中一共展示了Database.ExecuteNonQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStoredProcedures
public static void CreateStoredProcedures(Database db)
{
string sql = "create procedure RegionSelect as " +
"select * from Region Order by RegionId";
DbCommand command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionInsert (@RegionID int, @RegionDescription varchar(100) ) as " +
"insert into Region values(@RegionID, @RegionDescription)";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionUpdate (@RegionID int, @RegionDescription varchar(100) ) as " +
"update Region set RegionDescription = @RegionDescription where RegionID = @RegionID";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionDelete (@RegionID int) as " +
"delete from Region where RegionID = @RegionID";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
}
示例2: CreateStoredProcedures
public static void CreateStoredProcedures(Database db)
{
DbCommand command;
string sql;
sql = "create procedure RegionSelect (cur_OUT OUT PKGENTLIB_ARCHITECTURE.CURENTLIB_ARCHITECTURE) as " +
"BEGIN OPEN cur_OUT FOR select * from Region Order By RegionId; END;";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionInsert (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
"BEGIN insert into Region values(vRegionID, vRegionDescription); END;";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionUpdate (vRegionID IN Region.RegionID%TYPE, vRegionDescription IN Region.RegionDescription%TYPE) as " +
"BEGIN update Region set RegionDescription = vRegionDescription where RegionID = vRegionID; END;";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "create procedure RegionDelete (vRegionID IN Region.RegionID%TYPE) as " +
"BEGIN delete from Region where RegionID = vRegionID; END;";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
}
示例3: btnChangeStatus_OnCommand
protected void btnChangeStatus_OnCommand(object sender, CommandEventArgs e)
{
Database db=new Database();
db.AddParameter("@id", e.CommandArgument.ToString());
db.ExecuteNonQuery("update FileComment set Status=1-Status where [email protected]");
LoadData();
}
示例4: DeleteStoredProcedures
public static void DeleteStoredProcedures(Database db)
{
DbCommand command;
string sql = "drop procedure RegionSelect";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "drop procedure RegionInsert";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "drop procedure RegionDelete";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
sql = "drop procedure RegionUpdate";
command = db.GetSqlStringCommand(sql);
db.ExecuteNonQuery(command);
}
示例5: btnSend_OnClick
protected void btnSend_OnClick(object sender, EventArgs e)
{
if (ValidateData())
{
string filename = DateTime.Now.Ticks + "_" + System.IO.Path.GetFileName(fileImage.PostedFile.FileName);
fileImage.PostedFile.SaveAs(Server.MapPath("~/images/Researchers/")+filename);
Database db = new Database();
var lang=new Lang();
db.AddParameter("@name", txtName.Text);
db.AddParameter("@countrty", ddlCountry.SelectedValue);
db.AddParameter("@major", txtMajor.Text);
db.AddParameter("@level", ddlDegree.SelectedValue);
db.AddParameter("@Organization", txtWorkPlace.Text);
db.AddParameter("@Email", txtEmail.Text);
db.AddParameter("@Phone", txtPhone.Text);
db.AddParameter("@facebook", txtFacebook.Text);
db.AddParameter("@Twitter", txtTwitter.Text);
db.AddParameter("@Linkedin", txtLinkedin.Text);
db.AddParameter("@Prev", txtPrev.Text);
db.AddParameter("@Img", filename);
db.AddParameter("@lang", new Lang().getCurrentLang());
db.ExecuteNonQuery(
"insert into Researcher(name,country,major,level,Organization,Email,Phone,facebook,Twitter,Linkedin,Prev,Img,lang) values(@name,@countrty,@major,@level,@Organization,@Email,@Phone,@facebook,@Twitter,@Linkedin,@Prev,@Img,@lang)");
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert1", "alertify.alert('" + lang.getByKey("") + "','" + lang.getByKey("ResearchSubmitSuccessfully") + "').set('onok', function(closeEvent){ location.href='/Experts.aspx';} );", true);
}
}
示例6: btnDelete_OnCommand
protected void btnDelete_OnCommand(object sender, CommandEventArgs e)
{
Database db=new Database();
db.AddParameter("@id", e.CommandArgument.ToString());
db.ExecuteNonQuery("delete from UserFav where [email protected]");
LoadData();
ShowAlert("تم حذف الملف من قائمة الملفات المفضلة",MsgType.Success);
}
示例7: btnDelete_Command
protected void btnDelete_Command(object sender, CommandEventArgs e)
{
Database db = new Database(); string sql = string.Empty;
db.AddParameter("@id", e.CommandArgument.ToString());
db.ExecuteNonQuery("delete from " + tablename + " where id [email protected];delete from ConectedDoc where masterdocid [email protected]");
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
LoadData();
}
示例8: AddTestData
public static void AddTestData(Database db)
{
string sql =
"insert into Region values (99, 'Midwest');" +
"insert into Region values (100, 'Central Europe');" +
"insert into Region values (101, 'Middle East');" +
"insert into Region values (102, 'Australia')";
DBCommandWrapper testDataInsertion = db.GetSqlStringCommandWrapper(sql);
db.ExecuteNonQuery(testDataInsertion);
}
示例9: btnDelete_Command
protected void btnDelete_Command(object sender, CommandEventArgs e)
{
Database db = new Database(); string sql = string.Empty;
sql = "delete from " + tablename + " where id =" + e.CommandArgument;
if (db.ExecuteNonQuery(sql) >= 1)
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
}
LoadData();
}
示例10: CreateTestDatabase
public static void CreateTestDatabase(string connectionString, string sqlScriptSource)
{
using (var conn = new SqlConnection(connectionString))
{
conn.Open();
var server = new Server(conn);
var database = new Database(server, "MABMoney_TEST");
database.Create();
var schemaSql = File.ReadAllText(sqlScriptSource + @"\all.sql");
database.ExecuteNonQuery(schemaSql);
var seedSql = File.ReadAllText(sqlScriptSource + @"\test.sql");
database.ExecuteNonQuery(seedSql);
}
}
示例11: btnContactDelete_Click
protected void btnContactDelete_Click(object sender, EventArgs e)
{
Database db = new Database();
HiddenField id, file;
ArrayList arrlist = new ArrayList();
int x = 0;
foreach (ListViewItem rptItem in RepeaterLists.Items)
{
CheckBox chk = (CheckBox)rptItem.FindControl("CheckBox1");
if (chk.Checked)
{
id = (HiddenField)RepeaterLists.Items[x].FindControl("id");
file = (HiddenField)RepeaterLists.Items[x].FindControl("file");
if (!string.IsNullOrWhiteSpace(file.Value))
{
System.IO.File.Delete(Server.MapPath("~/SystemFiles/FilesAttach/" + file.Value));
}
arrlist.Add(id.Value);
}
x++;
}
string sql = string.Empty;
sql = "delete from " + tablename + " where id in (";
if (arrlist.Count > 0)
{
for (int i = 0; i < arrlist.Count; i++)
{
if (i == 0)
{
sql += arrlist[i].ToString();
}
else
{
sql += "," + arrlist[i].ToString();
}
}
sql += ")";
if (db.ExecuteNonQuery(sql) >= 1)
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح\")</SCRIPT>", false);
}
LoadData();
CheckBox10.Checked = false;
}
}
示例12: btnSendMsg_OnClick
protected void btnSendMsg_OnClick(object sender, EventArgs e)
{
Database db = new Database();
db.AddParameter("@from", DBNull.Value);
db.AddParameter("@title", txtTitle.Text);
string msg = "البريد الالكتروني : " + txtEmail.Text + "<br/>";
msg += txtMsg.Text;
db.AddParameter("@msg", msg);
db.ExecuteNonQuery("insert into msg([from],title,msg) values(@from,@title,@msg)");
ClientScript.RegisterClientScriptBlock(GetType(), "Alert-Msg", "alert('تم ارسال الرسالة الى مدير الموقع');", true);
}
示例13: CreateStoredProcedures
public static void CreateStoredProcedures(Database db)
{
string sql =
"CREATE PROCEDURE RegionSelect2 () " + Environment.NewLine +
"DYNAMIC RESULT SETS 1" + Environment.NewLine +
"P1: BEGIN " + Environment.NewLine +
"DECLARE cursor1 CURSOR WITH RETURN FOR " + Environment.NewLine +
"select * from Region Order by RegionId; " + Environment.NewLine +
"OPEN cursor1; " + Environment.NewLine +
"END P1";
DBCommandWrapper command = db.GetSqlStringCommandWrapper(sql);
db.ExecuteNonQuery(command);
sql =
"CREATE procedure RegionInsert2 (IN RegionID INTEGER, IN RegionDescription VARCHAR(100)) " + Environment.NewLine +
"P1: BEGIN " + Environment.NewLine +
"insert into Region values(RegionID, RegionDescription);" + Environment.NewLine +
"END P1";
command = db.GetSqlStringCommandWrapper(sql);
db.ExecuteNonQuery(command);
sql =
"CREATE procedure RegionUpdate (IN vRegionID INTEGER, IN vRegionDescription VARCHAR(100)) " + Environment.NewLine +
"P1: BEGIN " + Environment.NewLine +
"update Region set RegionDescription = vRegionDescription where RegionID = vRegionID;" + Environment.NewLine +
"END P1";
command = db.GetSqlStringCommandWrapper(sql);
db.ExecuteNonQuery(command);
sql =
"CREATE procedure RegionDelete2 (IN vRegionID INTEGER) " + Environment.NewLine +
"P1: BEGIN " + Environment.NewLine +
"delete from Region where RegionID = vRegionID;" + Environment.NewLine +
"END P1";
command = db.GetSqlStringCommandWrapper(sql);
db.ExecuteNonQuery(command);
}
示例14: btnDelete_Command
protected void btnDelete_Command(object sender, CommandEventArgs e)
{
// ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.confirm(\"This is a confirm dialog\",function(e){if(e){alertify.success(\"You've clicked OK\")}else{alertify.error(\"You've clicked Cancel\")}});</SCRIPT>", false);
Database db = new Database(); string sql = string.Empty;
sql = "delete from " + tablename + " where id =" + e.CommandArgument;
if (db.ExecuteNonQuery(sql) >= 1)
{
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح.\")</SCRIPT>", false);
} LoadData();
}
示例15: btnContactDelete_Click
protected void btnContactDelete_Click(object sender, EventArgs e)
{
Database db = new Database();
HiddenField id, file;
ArrayList arrlist = new ArrayList();
int x = 0;
foreach (ListViewItem rptItem in RepeaterLists.Items)
{
CheckBox chk = (CheckBox)rptItem.FindControl("CheckBox1");
if (chk.Checked)
{
id = (HiddenField)RepeaterLists.Items[x].FindControl("id");
arrlist.Add(id.Value);
}
x++;
}
string sql = string.Empty,sql2=String.Empty;
sql = "delete from " + tablename + " where id in (";
sql2 = "delete from ConectedDoc where masterdocid in (";
if (arrlist.Count > 0)
{
for (int i = 0; i < arrlist.Count; i++)
{
if (i == 0)
{
sql += arrlist[i].ToString();
sql2 += arrlist[i].ToString();
}
else
{
sql += "," + arrlist[i].ToString();
sql2 += "," + arrlist[i].ToString();
}
}
sql += ")";
sql2 += ")";
db.ExecuteNonQuery(sql + ";" + sql2);
ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "WriteMsg", "<SCRIPT LANGUAGE=\"JavaScript\">alertify.success(\"تم الحذف بنجاح\")</SCRIPT>", false);
LoadData();
CheckBox10.Checked = false;
}
}