本文整理汇总了C#中DBHelper.Update方法的典型用法代码示例。如果您正苦于以下问题:C# DBHelper.Update方法的具体用法?C# DBHelper.Update怎么用?C# DBHelper.Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBHelper
的用法示例。
在下文中一共展示了DBHelper.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryTest
public void QueryTest()
{
// arrange
DBHelper.Sqldb dbType = DBHelper.Sqldb.OrderWrite;
DBHelper db = new DBHelper();
string sql = "SELECT * FROM DealerServiceLog ";
var list = db.Query(sql).ToList();
var log = db.Query<DealerServiceLog>(21);
log.Description = "新增测试用例!!!";
db.Update(log);
// act
int count = list.Count;
// assert
Assert.AreEqual(7, count);
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack && Request.QueryString["v"] != null)
{
string id;
id = Request.QueryString["v"].ToString();
try
{
string appCode = Request["AppCode"];
if (string.IsNullOrEmpty(appCode))
appCode = "APP_01";
DBHelper hlp = new DBHelper(new BSD.FW.DBHelper.DBHelperConnection(this.ConnectionString, this.FactoryName));
if (hlp.GetDataSet("select * from vod_youtube where v_id='" + id + "'", "youtube").Tables[0].Rows.Count == 0)
{
string link = "http://www.youtube.com/watch?v=";
link += id;
/*
* Get the available video formats.
* We'll work with them in the video and audio download examples.
*/
WebProxy proxy = this.proxy();
IEnumerable<VideoInfo> videoInfos = DownloadUrlResolver.GetDownloadUrls(link ,proxy,System.Text.Encoding.UTF8 );
VideoInfo video = videoInfos.First(info => info.VideoType == VideoType.Mp4 && info.Resolution == 360);
WebClient client = new WebClient();
client.Proxy = proxy;
Response.Write(Server.MapPath("ffmpeg/ffmpeg.exe") + "<br>");
client.DownloadFile(video.DownloadUrl, Server.MapPath(id + ".mp4"));
System.Diagnostics.ProcessStartInfo p;
p = new System.Diagnostics.ProcessStartInfo(Server.MapPath("ffmpeg/ffmpeg.exe"), "-i \"" + Server.MapPath(id + ".mp4") + "\" -vcodec copy -acodec copy -vbsf h264_mp4toannexb \"" + Server.MapPath(id + ".ts") + "\"");
p.CreateNoWindow = true;
Process _p = new Process();
_p.StartInfo = p;
_p.Start();
_p.WaitForExit();
//Response.Clear();
//Response.TransmitFile(Server.MapPath(id + ".ts"));
_p.Close();
_p.Dispose();
// string sql = @"INSERT INTO VOD_YOUTUBE(V_ID,TITLE,PUBLISH_DATE,APP_CODE,THUMNAIL_URL,CREATED_DATE,CREATED_BY)VALUES
// ('" + id + "','" + video.Title + "',sysdate,'" + appCode + "','',sysdate,'VOD')";
// hlp.ExecuteNonQuery(sql);
string sql = "select * from VOD_YOUTUBE where 1<>1";
System.Data.DataTable dt = hlp.GetDataSet(sql, "VOD_YOUTUBE").Tables[0];
System.Data.DataRow dr = dt.NewRow();
dr["V_ID"] = id;
dr["TITLE"] = video.Title;
dr["PUBLISH_DATE"] = DateTime.Now ;
dr["THUMNAIL_URL"] = video.ThumnailUrl;
dr["APP_CODE"] = appCode;
dr["CREATED_DATE"] = DateTime.Now;
dr["CREATED_BY"] = "VOD";
dt.Rows.Add(dr);
hlp.Update(dt.DataSet);
string fName = Server.MapPath(id + ".mp4");
//Delete mp4 file (temp file)
if (System.IO.File.Exists(fName))
System.IO.File.Delete(fName);
Response.Write("{ \"status\":200, \"description\":\"Success\"}");
}
}
catch (Exception ex)
{
string fName = Server.MapPath(id + ".mp4");
//Delete mp4 file
if (System.IO.File.Exists(fName))
System.IO.File.Delete(fName);
//Delete ts file
fName = Server.MapPath(id + ".ts");
if (System.IO.File.Exists(fName))
System.IO.File.Delete(fName);
Response.Write(ex.Message);
}
}
}