本文整理汇总了C#中DBManager.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DBManager.ExecuteNonQuery方法的具体用法?C# DBManager.ExecuteNonQuery怎么用?C# DBManager.ExecuteNonQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBManager
的用法示例。
在下文中一共展示了DBManager.ExecuteNonQuery方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubmitChanges
/// <summary>
/// Ekleme, silme veya güncelleme gibi yapılmış olan işlemleri, veritabanında uygulamayı sağlar.
/// Allows you to perform insert, delete or update operations on the database.
/// </summary>
/// <returns></returns>
public int SubmitChanges()
{
var dbManager = new DBManager(OrmConfiguration);
dbManager.CreateCommand(DBManager.CommandText);
if (DBManager.CommandParameters != null && DBManager.CommandParameters.Count > 0)
foreach (var loopParameter in DBManager.CommandParameters)
{
dbManager.AddParameter(loopParameter.Key.ToString(), loopParameter.Value);
}
int status = dbManager.ExecuteNonQuery();
return status;
}
示例2: DeleteColumnFromDBTable
//Delete a table column
public static void DeleteColumnFromDBTable(String TableName, string ColumnName)
{
// first it drops this column then it delete a record in design table for this deleted column
string SQL = @"ALTER TABLE " + TableName +
" Drop Column " + ColumnName;
DBManager db = new DBManager();
db.ExecuteNonQuery(SQL);
}
示例3: ModifyColumnSize
public static void ModifyColumnSize(String TableName, string ColumnName, int Size)
{
string SQL = string.Empty;
SQL = @"ALTER TABLE " + TableName + " ALTER COLUMN " + ColumnName + " NVARCHAR (" + Size.ToString() + ") NULL ";
DBManager db = new DBManager();
db.ExecuteNonQuery(SQL);
}
示例4: ModifyDBTableColumn
public static void ModifyDBTableColumn(String TableName, string ColumnName, string DataType, string oldColumnName)
{
string SQL = string.Empty;
SQL = @"sp_RENAME '" + TableName + "." + oldColumnName + "','" + ColumnName + "', 'COLUMN'";
DBManager db = new DBManager();
db.ExecuteNonQuery(SQL);
//DeleteColumn
}
示例5: UpdateFormDesignPosition
//Modify a table column
public static void UpdateFormDesignPosition(String SQL)
{
DBManager db = new DBManager();
db.ExecuteNonQuery(SQL);
}
示例6: VM_set_adapter
//暫時 FOR VMWARE creat adapter
static void VM_set_adapter(string[] vlan_id, string[] virNetworkName_m, string guid, string vmware_datacenter_name, string vmware_host_name, string order_id)
{
try
{
Create_VM_Service.AutoProvision_WS.AutoProvision_WS ws = new Create_VM_Service.AutoProvision_WS.AutoProvision_WS();
Create_VM_Service.VMAPI.GCCA_HypervisorAPI vmapi = new GCCA_HypervisorAPI();
#region cleaning adapter and database data
/////cleaning adapter and database data
List<JToken> adapter_detail = new List<JToken>();
string clean = vmapi.getVMNICMacList(guid, vmware_datacenter_name, vmware_host_name, order_id);
JToken token;
token = JToken.Parse(clean.Remove(clean.Length - 1).Remove(0, 1).Replace("\\", "\\\\"));
token.SelectToken("message")[1].SelectToken("Mac").ToString();
for (int i = 1; i < token.SelectToken("message").Count(); i++) // colculate adapter num
{
string temp = vmapi.removeVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, token.SelectToken("message")[i].SelectToken("Nic_Name").ToString(), token.SelectToken("message")[1].SelectToken("Mac").ToString()).ToString();
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " removeVMNIC is : " + temp + + Environment.NewLine);
}
DBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "@order_id", order_id);
string sql = "";
sql = @"DELETE FROM order_nic_mac_list
WHERE order_id = @order_id";
int updateOderId = dbManager.ExecuteNonQuery(CommandType.Text, sql);
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " change DB data number : " + updateOderId + +Environment.NewLine);
clean_IP(order_id);
//////////////
#endregion
List<string> NetworkName = new List<string>();
int j_test = 0;//單純控制下面迴圈
int j_result = 1;//控制下面迴圈
for (int i = 0; i < vlan_id.Length; i++) // 找出VM上符合訂單上VLAN_ID的網卡名稱
{
while (i < vlan_id.Length)
{
j_result = string.Compare(vlan_id[i], virNetworkName_m[j_test]);
if (j_result == 0)
{
NetworkName.Add(virNetworkName_m[j_test - 2]);
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " virNetworkName_m is : " + virNetworkName_m[j_test - 2] + +Environment.NewLine);
break;
}
j_test++;
}
j_test = 0;
j_result = 1;
}
for (int i = 0; i < vlan_id.Length; i++)//如果有多張網卡 建立多張網卡
{
if (i == 0)//if 只有一張網卡,更改網卡名稱
{ vmapi.adjustVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, "Network adapter 1", NetworkName[i]); }//修改網卡內容 只有一張網卡時 修改第一張
//string ggg= vlan_id[];
else
{ vmapi.addVMNIC(guid, vmware_datacenter_name, vmware_host_name, order_id, NetworkName[i]); }
}
string nic_mac_list = vmapi.getVMNICMacList(guid, vmware_datacenter_name, vmware_host_name, order_id);
//string[] nic_mac_list2 = nic_mac_list.Split(new string[2]{"\"Mac\":\"","\"}"}, StringSplitOptions.RemoveEmptyEntries); //對API回傳的值做切割,
string[] nic_mac_list2 = nic_mac_list.Split(new string[4] { "Nic_Name\":\"", "\",", "\"Mac\":\"", "\"}" }, StringSplitOptions.RemoveEmptyEntries); //字串分割 Nic_Name":" ", Mac":" "}
int j_i = 0;
for (int i = 0; i < vlan_id.Length; i++)//將網卡MAC等資料 塞回DB
{
j_i = 3 * i; //只要陣列中的 i*3+(1or2)的值
ws.save_nic_mac(order_id, nic_mac_list2[j_i + 1], nic_mac_list2[j_i + 2], vlan_id[i], vmware_host_name); //將creat VM的資料(order_id,macID,nic_id,groupID,order_area,vlan_id,host_name) 塞回DB
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", " save_nic_mac: " + order_id + " " + nic_mac_list2[j_i + 1] + " " + nic_mac_list2[j_i + 2] + " " + vlan_id[i] + " " + vmware_host_name + " " + +Environment.NewLine);
}
dbManager.Dispose();
}
catch (Exception)
{
return;
}
}
示例7: de_bug
//.........这里部分代码省略.........
string create_on_hostname = "";
string create_on_datacentername = "";
string resource_pool_name = "";
string guid = "";
bool exist_group_flag = false;
bool create_flag = false;
#region 是否有訂單需建立 need create vm have group(?)
if (nCount == 1) // 根本一次只能建立一筆xddd
{
group_id = ds.Tables[0].Rows[0]["group_id"].ToString();
company_id = ds.Tables[0].Rows[0]["company_id"].ToString();
order_id = ds.Tables[0].Rows[0]["order_id"].ToString();
os = ds.Tables[0].Rows[0]["os"].ToString();
vmtype = ds.Tables[0].Rows[0]["order_vm_type"].ToString();
order_area = ds.Tables[0].Rows[0]["order_area"].ToString();
temp_id = ds.Tables[0].Rows[0]["temp_id"].ToString();
order_vm_type = ds.Tables[0].Rows[0]["order_vm_type"].ToString();
vpath = ds.Tables[0].Rows[0]["vpath"].ToString();
cpu = ds.Tables[0].Rows[0]["order_cpu"].ToString();
ram = Convert.ToString(Convert.ToInt16(ds.Tables[0].Rows[0]["order_ram"].ToString()) * 1024);
add_nic_num = ds.Tables[0].Rows[0]["vlan_id"].ToString().Split(',').Count() - 1;
vlan_id = ds.Tables[0].Rows[0]["vlan_id"].ToString().Split(',');
hdSize = ds.Tables[0].Rows[0]["order_nhd"].ToString();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "order_id", order_id);
sql = @"UPDATE user_vm_order
SET order_audit='3',upd_datetime=getdate()
WHERE [email protected]_id
update user_vm_order
set create_time=getdate()
where [email protected]_id";
result = dbManager.ExecuteNonQuery(CommandType.Text, sql);
if (group_id != "")//有群組的話
{
ws.Inset_Percent(order_id, "10", "");
if (vmtype == "KVM")
{
System.IO.File.AppendAllText(@"C:\AutoProvision\logs.txt", "order_id is : " + order_id + " VMtype is : " + vmtype + Environment.NewLine);
dbManager.CreateParameters(4);
dbManager.AddParameters(0, "@order_area", order_area);
dbManager.AddParameters(1, "@company_id", company_id);
dbManager.AddParameters(2, "@vmtype", vmtype);
dbManager.AddParameters(3, "@temp_id", temp_id);
sql = @"SELECT kvm_account,kvm_dsname,kvm_hostname,kvm_pwd,b.hostname as create_on_hostname
FROM config_vm_host a left outer join vm_temp b on a.vmtype=b.vm_type
WHERE [email protected]_area and [email protected]_id and [email protected] and [email protected]_id";
ds = dbManager.ExecuteDataSet(CommandType.Text, sql);
nCount = ds.Tables[0].Rows.Count;
if (nCount == 1)//如果KVM只有一台HOST
{
#region assign host
kvm_account = ds.Tables[0].Rows[0]["kvm_account"].ToString();
kvm_dsname = ds.Tables[0].Rows[0]["kvm_dsname"].ToString();
kvm_hostname = ds.Tables[0].Rows[0]["kvm_hostname"].ToString();
create_on_hostname = ds.Tables[0].Rows[0]["create_on_hostname"].ToString();
kvm_pwd = CryptoAES.decrypt(ds.Tables[0].Rows[0]["kvm_pwd"].ToString(), "[email protected]");
//string kvm_usage = ws.get_KVM_HOST_Usage(kvm_hostname, kvm_account, kvm_pwd);
//string kvm_vm_usage = ws.get_KVM_VM_Usage(kvm_hostname, kvm_dsname, kvm_account, kvm_pwd);
string[] guidf0 = vmapi.init(kvm_hostname, kvm_dsname, kvm_account, kvm_pwd).Split(':');
string[] guidf1 = guidf0[2].Split('\'');
// TODO: add comment
示例8: clean_IP
private static void clean_IP(string vmname)
{
string sql;
DBManager dbManager = new DBManager(DataProvider.SqlServer);
dbManager.ConnectionString = ConfigurationManager.AppSettings["SSM"].ToString();
dbManager.Open();
dbManager.CreateParameters(1);
dbManager.AddParameters(0, "@order_id", vmname);
sql = @"update c_ip_list
set ip_address=(select substring(ip_address,0,case charindex(':',ip_address) when '' then Len(ip_address)+1 else charindex(':',ip_address) end) from c_ip_list a where c_ip_list.row_id=a.row_id),order_id=NULL,used=NULL,upd_userid='Service',used_mac=NULL,upd_datetime=GETDATE()
where order_id [email protected]_id";
int updateOderId = dbManager.ExecuteNonQuery(CommandType.Text, sql);
dbManager.Dispose();
}
示例9: SaveTabsData
public void SaveTabsData(Int64 IDValue, Panel oPanel, string DBTable, int eFromID, string IDColumnName)
{
DataTable oDt = DesignFormField.GetDataTableStructure(DBTable, IDColumnName, IDValue);
DataTable oSaveDT = new DataTable();
FormDesign oDesign = new FormDesign();
oSaveDT = SetTabValueIntoDataSet(oDt, false, oPanel, "", DBTable);
string sql = CreateQuerStatement(IDValue, oSaveDT, DBTable, IDColumnName);
DBManager odbm = new DBManager();
odbm.ExecuteNonQuery(sql);
}