本文整理汇总了C#中Dbconn.GetDataTableRowCount方法的典型用法代码示例。如果您正苦于以下问题:C# Dbconn.GetDataTableRowCount方法的具体用法?C# Dbconn.GetDataTableRowCount怎么用?C# Dbconn.GetDataTableRowCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dbconn
的用法示例。
在下文中一共展示了Dbconn.GetDataTableRowCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// 编辑任务参数信息
/// </summary>
/// <returns></returns>
public bool Execute()
{
Dbconn conn = new Dbconn("MDM"); //创建连接类
try
{
if (m_request == null
|| m_request.Tables.Count == 0
|| m_request.Tables[0].Rows.Count == 0)
{
return true;
}
string strTASK_ID = m_request.Tables[0].Rows[0]["task_id"].ToString(); //获取参数Task_ID
string strParam_Name = m_request.Tables[0].Rows[0]["param_name"].ToString(); //获取参数Param_Name
string strParam_ID = m_request.Tables[0].Rows[0]["param_id"].ToString(); //获取参数Param_ID
ArrayList listTable = new ArrayList();
listTable.Add("WS_SchedulingParam");
conn.BeginTransaction(); //开启事务
conn.TableLock(listTable); //锁表WS_SchedulingParam
string strWhere = " 1=1 ";
if (!string.IsNullOrEmpty(strTASK_ID))
{
strWhere += " AND TASK_ID = '" + strTASK_ID + "'";
}
if (!string.IsNullOrEmpty(strParam_Name))
{
strWhere += " AND Param_Name = '" + strParam_Name + "'";
}
//创建DataTable
DataTable dt_Add = new DataTable();
dt_Add.Columns.Add("Param_ID");
dt_Add.Columns.Add("TASK_ID");
dt_Add.Columns.Add("Param_Name");
dt_Add.Columns.Add("Param_Value");
DataRow dr = dt_Add.NewRow();
for (int i = 0; i < dt_Add.Columns.Count; i++)
{
dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString(); //将m_request中的数据逐个赋值
}
dt_Add.Rows.Add(dr);
if (strParam_ID == "") //如果为空,说明是复制数据
{
//判断是否已经存在
int nRow = conn.GetDataTableRowCount("SELECT * FROM WS_SchedulingParam WHERE " + strWhere, new string[0]);
if (nRow > 0)
{
throw new Exception(strParam_Name + "已经存在,不能更新");
}
strParam_ID = Guid.NewGuid().ToString(); //创建GUID
dt_Add.Rows[0]["Param_ID"] = strParam_ID;
conn.Insert("WS_SchedulingParam", dt_Add); //插入数据
}
else
{
dt_Add.Columns.Remove("Param_ID"); //删除Param_ID,更新不需要
dt_Add.Columns.Remove("Task_ID"); //删除Task_ID,更新不需要
strWhere = " 1=1 AND Param_ID = '" + strParam_ID + "'"; //重新设置where语句
conn.Update("WS_SchedulingParam", dt_Add, strWhere); //更新数据
}
//更新主表
DataTable dtScheduling = new DataTable();
dtScheduling.Columns.Add("UpdateTime");
DataRow drScheduling = dtScheduling.NewRow();
drScheduling["UpdateTime"] = DateTime.Now;
dtScheduling.Rows.Add(drScheduling);
string strSchedulingWhere=" 1=1 AND TASK_ID = '" + strTASK_ID + "'";
conn.Update("WS_Scheduling", dtScheduling, strSchedulingWhere); //更新数据
conn.CommitTransaction();
return true;
}
catch
{
conn.RollbackTransaction();
throw;
}
}
示例2: Execute
public bool Execute()
{
Dbconn conn = new Dbconn("AM");
Dbconn connMDM = new Dbconn("VexSSO");
conn.BeginTransaction();
connMDM.BeginTransaction();
try
{
DataSet ds = conn.GetDataSet(
@"
DECLARE @maxid AS BINARY(10);
SELECT t1.[__$start_lsn] AS LogID,
t1.[__$seqval] ,
t1.[__$operation] OprationType ,
t1.CN_ID ,
t1.CN_LOGIN ,
t1.CN_USER_NAME ,
t1.CN_PASSWORD ,
Convert(int,t1.CN_ISDELETE) as CN_ISDELETE ,
Convert(int,t1.CN_DISABLED) as CN_DISABLED
INTO #tmp
FROM [cdc].[dbo_TN_SYS_EM_USER_CT] t1 ,
[M01_CONF].[S01_Sync] t2
WHERE 1=1
AND t1.[__$start_lsn]> ISNULL(t2.MaxStart_lsn,0x00023FE600000FBF0004)
AND t2.SyncName='MDM数据获取'
AND t1.[__$update_mask] !=0x00004000
AND t1.[__$update_mask] !=0x00800000
AND t1.[__$update_mask] !=0x00804000
SELECT @maxid=MAX(LogID)
FROM #tmp
if(@maxid is not null)
begin
UPDATE [M01_CONF].[S01_Sync] SET [email protected]
WHERE SyncName='MDM数据获取'
end
select * from #tmp
order by [LogID] ASC,[__$seqval] ASC ,[OprationType] ASC
");
string strSQL = "";
Byte[] strMaxID = null;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strMaxID = (Byte[])ds.Tables[0].Rows[i]["LogID"];
string strCN_LOGIN = ds.Tables[0].Rows[i]["CN_LOGIN"].ToString();
string strCN_PASSWORD = ds.Tables[0].Rows[i]["CN_PASSWORD"].ToString();
string strCN_ISDELETE = ds.Tables[0].Rows[i]["CN_ISDELETE"].ToString();
string strOprationType = ds.Tables[0].Rows[i]["OprationType"].ToString();
if (strOprationType == "1" || strOprationType == "4") //添加或者更新
{
if (connMDM.GetDataTableRowCount("select 1 as a from MDM_Employees where [email protected]", new string[] { strCN_LOGIN }) == 0)
{
strSQL = @"INSERT INTO MDM_Employees (Name,SSO_UserName,SSO_Password,Leave_Flag,IsActived)
Values(@param0,@param1,@param2,@param3,'1')";
}
else
{
strSQL = @"update MDM_Employees
SET [email protected],[email protected]
WHERE [email protected]
";
}
connMDM.ExcuteQuerryByTran(strSQL, new string[] { strCN_LOGIN, strCN_LOGIN, strCN_PASSWORD, strCN_ISDELETE });
}
else if (strOprationType == "2" || strOprationType == "3") //删除
{
strSQL = @"update MDM_Employees
SET [email protected]
WHERE [email protected]";
connMDM.ExcuteQuerryByTran(strSQL, new string[] { "1", strCN_LOGIN });
}
}
if (strMaxID != null)
{
strSQL = "UPDATE M01_CONF.S01_Sync SET [email protected],LastSyncTime=getdate() WHERE SyncName='MDM数据获取'";
conn.ExcuteQuerryByTran(strSQL, new object[] { strMaxID });
}
conn.CommitTransaction();
connMDM.CommitTransaction();
return true;
}
catch
{
//.........这里部分代码省略.........
示例3: UpdateFullText
public static void UpdateFullText(string pstrWSID, Dbconn pconn)
{
string strSQL = @"
DECLARE @cols NVARCHAR(MAX)
SET @cols = ''
SELECT @cols = @cols + 'convert(varchar(1000),isnull(' + name
+ ',''''),21)+'' ''+'
FROM syscolumns
WHERE ( id = ( SELECT id
FROM sysobjects
WHERE ( name = 'WS0E_WSExtDoc' )
) )
SELECT @cols as A
";
string strInfoColumns = pconn.GetDataTableFirstValue(strSQL).ToString();
strSQL = strInfoColumns.Substring(0, strInfoColumns.Length - 1);
strSQL = "SELECT " + strSQL + " FROM [B01_MDM].[WS0E_WSExtDoc] WHERE [email protected]";
string strValue = pconn.GetDataTableFirstValue(strSQL, new string[] { pstrWSID }).ToString();
strSQL = @"
DECLARE @cols NVARCHAR(MAX)
SET @cols = ''
SELECT @cols = @cols + 'convert(varchar(1000),isnull(' + name
+ ',''''),21)+'' ''+'
FROM syscolumns
WHERE ( id = ( SELECT id
FROM sysobjects
WHERE ( name = 'WS0M_WSMethodDoc' )
) )
SELECT @cols as A
";
string strFunctionColumns = pconn.GetDataTableFirstValue(strSQL).ToString();
strSQL = "SELECT " + strFunctionColumns.Substring(0, strFunctionColumns.Length - 1) + " AS A FROM [B01_MDM].[WS0M_WSMethodDoc] WHERE [email protected]";
DataTable dt = pconn.GetDataTable(strSQL, new string[] { pstrWSID });
for (int i = 0; i < dt.Rows.Count; i++)
{
strValue += " " + dt.Rows[i]["A"].ToString();
}
strSQL = " SELECT 1 AS A FROM [B05_RPT].[WS0V_WSMethodView] WHERE [email protected]";
if (pconn.GetDataTableRowCount(strSQL, new string[] { pstrWSID }) == 1)
{
pconn.ExcuteQuerryByTran("UPDATE [B05_RPT].[WS0V_WSMethodView] SET [email protected] WHERE [email protected]", new string[] { strValue, pstrWSID });
}
else
{
pconn.ExcuteQuerryByTran("INSERT INTO [B05_RPT].[WS0V_WSMethodView](fulltext,WSID)Values(@Param0,@PARAM1)", new string[] { strValue, pstrWSID });
}
}
示例4: CheckName
private bool CheckName(DataTable dt, Dbconn conn)
{
bool bResult = true;
if (dt.Columns.Contains("Template_Name"))
{
string strTemplate_ID = "";
string strEnvo_ID = "";
if (dt.Columns.Contains("Template_ID"))
{
strTemplate_ID = dt.Rows[0]["Template_ID"].ToString();
}
if (dt.Columns.Contains("Envo_ID"))
{
strEnvo_ID = dt.Rows[0]["Envo_ID"].ToString();
}
string strEnvo_Name = dt.Rows[0]["Template_Name"].ToString();
if (conn.GetDataTableRowCount("select Template_ID from [EnvoTemplates] where [email protected] and [Template_Name][email protected] and [email protected]", new string[3] { strTemplate_ID, strEnvo_Name,strEnvo_ID }) > 0)
{
bResult = false;
}
}
return bResult;
}
示例5: GetData
//.........这里部分代码省略.........
}
dt.Rows[0]["Table_Templete"] = Microsoft.JScript.GlobalObject.escape(strTableTemplete);
dt.Columns.Add("timestamps");
dt.Rows[0]["timestamps"] = ds_ITSMSR_Response.Tables[0].Rows[0]["timestamps"];
ds_Return.Tables.Add(dt.Copy());
}
else if (ds.Tables["OPTYPE"].Rows[0][0].ToString().ToUpper() == "EDIT")
{
strCheck_ID = ds.Tables["LIST"].Rows[0]["ID"].ToString();
strCheck_User = ds.Tables["LIST"].Rows[0]["Check_User"].ToString();
strCheck_Result = ds.Tables["LIST"].Rows[0]["Check_Result"].ToString();
strCheck_RemarK = ds.Tables["LIST"].Rows[0]["Check_Remark"].ToString();
DataTable dtCheckList = conn.GetDataTable("SELECT * FROM Check_List WHERE ID='" + strCheck_ID + "'");
if (dt.Rows.Count == 0)
{
throw new Exception("该审核单已不存在,请联系管理员");
}
int nSeq_ID = Convert.ToInt32(dt.Rows[0]["Seq_Index"]);
//判断是否已经进行后续的审批
string strSql = "SELECT '1' as A from Check_List WHERE Check_Type='" + dt.Rows[0]["Check_Type"].ToString() + @"'
AND Key_ID='" + dt.Rows[0]["Key_ID"].ToString() + @"'
AND Check_Result is not null
AND Seq_Index>" + nSeq_ID.ToString() + "";
if (conn.GetDataTableRowCount(strSql) > 0)
{
throw new Exception("下一道的流程已经审批,本次审批不能再做修改!");
}
dtCheckList.Rows[0]["Check_User"] = strCheck_User;
dtCheckList.Rows[0]["Check_Date"] = DateTime.Now;
dtCheckList.Rows[0]["Check_Result"] = strCheck_Result;
dtCheckList.Rows[0]["Remark"] = strCheck_RemarK;
dtCheckList.Rows[0]["updateTime"] = DateTime.Now;
ArrayList listTable = new ArrayList();
listTable.Add("Check_List");
try
{
conn.BeginTransaction();
conn.TableLock(listTable);
//判断数据是否为最新数据
strSql = "SELECT timestamps+0 as timestamps from " + strRequestTableName
+ " WHERE Deleted=0 AND " + strKeyColumn + "='" + strKey_Value + "'";
string strTimestamps = conn.GetDataTableFirstValue(strSql).ToString();
if (strTimestamps != ds.Tables["LIST"].Rows[0]["timestamps"].ToString())
{
throw new Exception("原申请单数据已被修改,请刷新后重试!");
}
//dt.Columns.Remove("timestamps");
conn.Update("Check_List", dtCheckList, "ID='" + strCheck_ID + "'");
示例6: GetData
/// <summary>
/// 编辑成本中心信息
/// </summary>
/// <returns></returns>
public DataSet GetData()
{
Dbconn conn = new Dbconn("MDM_Master2");
Dbconn MDM_Market2_conn = new Dbconn("MDM_Market2");
try
{
DataSet ds_Return = new DataSet();
DataSet dsRequest = new DataSet();
string strXML = "";
strXML = m_request.Tables[0].Rows[0]["XML"].ToString();
if (strXML == "")
{
throw new Exception("提交的XML为空!");
}
DataSet dsXML = Common.Common.GetDSByExcelXML(strXML);
DataTable dt_OPTYPE = dsXML.Tables["OPTYPE"];
string strMDM_Class = "0025";
conn.LockTableList.Add("MDM_0025_B");
conn.LockTableList.Add("MDM_0025_E");
conn.BeginTransaction();
//获取所有属性
MDM2_GetEntityPropertyList cls = new MDM2_GetEntityPropertyList();
cls.hzyMessage = this.hzyMessage;
cls.MainEntity = strMDM_Class;
DataTable dtPorperty = cls.GetData().Tables[0];
for (int i = 0; i < dt_OPTYPE.Rows.Count; i++)
{
DataTable dt_List = dsXML.Tables[Common.Common.GetListTableName(i)];
string CheckEnvName = dt_List.Rows[0]["系统编号"].ToString();
string CheckBodyId = dt_List.Rows[0]["Body_ID"].ToString();
if (CheckBodyId == "")
{
if (MDM_Market2_conn.GetDataTableRowCount("SELECT * FROM MKT_0025 WHERE 系统编号='" + CheckEnvName + "'") > 0)
{
throw new Exception("系统编号:" + CheckEnvName + "已存在!");
}
}
else
{
if (MDM_Market2_conn.GetDataTableRowCount("SELECT * FROM MKT_0025 WHERE Body_ID !='" + CheckBodyId + "' AND 系统编号='" + CheckEnvName + "'") > 0)
{
throw new Exception("系统编号:" + CheckEnvName + "已存在!");
}
}
if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "UPDATE"
|| dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT"
)
{
//插入BODY表
for (int j = 0; j < dt_List.Rows.Count; j++)
{
string strBody_id = "";
strBody_id = dt_List.Rows[j]["body_ID"].ToString();
if (dt_OPTYPE.Rows[i][0].ToString().ToUpper() == "INSERT")
{
MDM2_EntityCreatedBodyID_Edit clsBody = new MDM2_EntityCreatedBodyID_Edit();
clsBody.Conn = conn;
clsBody.hzyMessage = hzyMessage;
clsBody.MDMClass = strMDM_Class;
clsBody.Execute();
strBody_id = clsBody.BodyID;
if (strBody_id == "")
{
throw new Exception("BodyID创建失败!");
}
}
else if (strBody_id == "")
{
throw new Exception("传入的参数有误,如果反复出现,请重新登录!");
}
for (int k = 0; k < dt_List.Columns.Count; k++)
{
string strColumnName = dt_List.Columns[k].ColumnName;
if (dtPorperty.Select("Property_Name='" + strColumnName + "'").Length == 0)
{
continue;
}
//.........这里部分代码省略.........
示例7: Execute
/// <summary>
/// 编辑WS信息
/// </summary>
/// <returns></returns>
public bool Execute()
{
Dbconn conn = new Dbconn("WSRR");
try
{
if(m_request == null
|| m_request.Tables.Count==0
|| m_request.Tables[0].Rows.Count == 0)
{
return true;
}
string strWS_ID = m_request.Tables[0].Rows[0]["WS_ID"].ToString();
string strWS_Name = m_request.Tables[0].Rows[0]["WS_Name"].ToString();
ArrayList listTable = new ArrayList();
listTable.Add("WS");
conn.BeginTransaction();
conn.TableLock(listTable);
string strWhere = " WS_Name='" + strWS_Name + "'";
if (strWS_ID != "")
{
strWhere += " AND WS_ID != '"+strWS_ID+"'";
}
//判断是否已经存在
int nRow = conn.GetDataTableRowCount("SELECT 'A' as A FROM WS WHERE " + strWhere, new string[0]);
if (nRow > 0)
{
throw new Exception(strWS_Name + "已经存在,不能更新");
}
DSWSRR.WSDataTable dt_Add = new DSWSRR.WSDataTable();
dt_Add.PrimaryKey = null;
dt_Add.Columns["WS_ID"].DataType = typeof(string);
string strWS_IDSrc = "";
if (m_request.Tables[0].Columns.Contains("WS_IDSrc"))
{
strWS_IDSrc = m_request.Tables[0].Rows[0]["WS_IDSrc"].ToString();
}
DataRow dr = dt_Add.NewRow();
for (int i = 0; i < dt_Add.Columns.Count-4; i++)
{
if (dt_Add.Columns[i].ColumnName == "WS_Host")
{
string strENV = ConfigurationManager.AppSettings["WSRR_ENV"];
if (strENV.ToLower() == "prod")
{
dr[i] = m_request.Tables[0].Rows[0]["WS_Host_Prod"].ToString();
}
else
{
dr[i] = m_request.Tables[0].Rows[0]["WS_Host_Test"].ToString();
}
}
else
{
dr[i] = m_request.Tables[0].Rows[0][dt_Add.Columns[i].ColumnName].ToString();
}
}
dt_Add.Rows.Add(dr);
if (strWS_ID == "") //如果为空,说明是复制数据
{
dt_Add.Columns.Remove("Update_User");
dt_Add.Columns.Remove("Update_Time");
strWS_ID = conn.GetDataTableFirstValue("SELECT NEWID() as ID").ToString();
dt_Add.Rows[0]["WS_ID"] = strWS_ID;
conn.Insert("WS", dt_Add);
//添加参数表的信息
DataTable dtParam = conn.GetDataTable("SELECT * FROM WS_Param WHERE WS_ID='" + strWS_IDSrc + "'");
//更新WSID
for (int i = 0; i < dtParam.Rows.Count; i++)
{
dtParam.Rows[i]["WS_ID"] = strWS_ID;
}
dtParam.Columns.Remove("Param_ID");
conn.Insert("WS_Param", dtParam);
}
else
{
//.........这里部分代码省略.........
示例8: Execute
/// <summary>
/// 编辑WS信息
/// </summary>
/// <returns></returns>
public bool Execute()
{
Dbconn conn = new Dbconn("WSRR");
try
{
if(m_request == null
|| m_request.Tables.Count==0
|| m_request.Tables[0].Rows.Count == 0)
{
return true;
}
ArrayList listTable = new ArrayList();
listTable.Add("WS_Param");
conn.BeginTransaction();
conn.TableLock(listTable);
for (int row = 0; row < m_request.Tables[0].Rows.Count; row++)
{
string strParam_ID = m_request.Tables[0].Rows[row]["Param_ID"].ToString();
string strParam_Index = m_request.Tables[0].Rows[row]["Param_Index"].ToString();
string strWS_ID = m_request.Tables[0].Rows[row]["WS_ID"].ToString();
string strWhere = " Param_Index='" + strParam_Index + "' AND WS_ID='" + strWS_ID + "'";
if (strParam_ID != "")
{
strWhere += " AND Param_ID != '" + strParam_ID + "'";
}
//判断是否已经存在
int nRow = conn.GetDataTableRowCount("SELECT 'A' as A FROM WS_Param WHERE " + strWhere, new string[0]);
if (nRow > 0)
{
throw new Exception("序号" + strParam_Index + "已经存在,不能更新");
}
DSWSRR.WS_ParamDataTable dt_Add = new DSWSRR.WS_ParamDataTable();
dt_Add.PrimaryKey = null;
dt_Add.Columns.Remove("Param_ID");
DataRow dr = dt_Add.NewRow();
for (int i = 0; i < dt_Add.Columns.Count - 1; i++)
{
dr[i] = m_request.Tables[0].Rows[row][dt_Add.Columns[i].ColumnName].ToString();
}
dt_Add.Rows.Add(dr);
if (strParam_ID == "")
{
conn.Insert("WS_Param", dt_Add);
}
else
{
strWhere = " Param_ID = '" + strParam_ID + "'";
conn.Update("WS_Param", dt_Add, strWhere);
}
}
conn.CommitTransaction();
return true;
}
catch
{
conn.RollbackTransaction();
throw;
}
}
示例9: CheckName
private bool CheckName(DataTable dt, Dbconn conn)
{
bool bResult = true;
if (dt.Columns.Contains("Envo_Name"))
{
string strEnvo_ID = "";
if (dt.Columns.Contains("Envo_ID"))
{
strEnvo_ID = dt.Rows[0]["Envo_ID"].ToString();
}
string strEnvo_Name = dt.Rows[0]["Envo_Name"].ToString();
if (conn.GetDataTableRowCount("select Envo_ID from [Envo] where [email protected] and [Envo_Name][email protected]", new string[2] { strEnvo_ID, strEnvo_Name }) > 0)
{
bResult = false;
}
}
return bResult;
}