首页 > 代码库 > 数据库操作:查找表、更新

数据库操作:查找表、更新

public string GetVideoIdbyVideoName(string videoName)
{
     string item = "";
     try
    {
          DBManager dBManager = this.GetDBManager(ConUtil.CaseId);
          if (dBManager == null)
          {
               logger.WarnFormat("未知的数据库库:{0}", ConUtil.CaseId);
               return null;
          }
         DbParameter[] array = dBManager.CreateDbParameters(1);
         array[0].ParameterName = "videoName";
         array[0].DbType = DbType.String;
         array[0].Value = http://www.mamicode.com/videoName;

  DataSet dataSet = dBManager.ExecuteDataSet(this.sqlProvider.GetVideoIdbyVideoNameSql, CommandType.Text, array);
  if (dataSet.Tables[0].Rows.Count > 0)
  {
       DataRow dataRow = dataSet.Tables[0].Rows[0];
       item = dataRow["ID"].ToString();

  }
 else
  {
      logger.Error("未找到对应的视频id");
      return null;
  }

   }

   catch (Exception exception)
   {
       logger.Warn("提交任务异常", exception);
       return null;
   }
   return item;
}

 

public string GetVideoIdbyVideoNameSql
{
     get
      {
           return "SELECT ID FROM VideoResource WHERE Name=@videoName";
       }
}

 

//矩形区域序列化,cropcoordinatexml 要传到数据库表

System.Drawing.Rectangle rect = new System.Drawing.Rectangle()
{
    X = xStart,
    Y = yStart,
    Width = width,
    Height = height
};
string cropcoordinatexml = SPGZ.ConUtilities.Misc.XmlHelper.ToXmlString<System.Drawing.Rectangle>(rect);

 

public string AddVideoAbClQueryResultSql
{
    get
    {
     return "INSERT INTO chart1 (TaskID,Similarity,ObjImgFileName,CropCoordinateXML) VALUES(@taskID,@similarity,@objImgFileName,@cropCoordinateXML) ;";
     }
}

 

数据库操作:查找表、更新