C# 存图片到数据库的问题

qyulang qyulang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
现在数据库里只能存文本,我想存入图片,这是存文本的代码

protected void Button1_Click(object sender, EventArgs e)
{
//保存
string strHeadID = this.txtHeadID.Text.Trim();
string strCataID = this.txtCataID.Text.Trim();
DateTime dtDateTime = DateTime.Now;
string strText = this.txtText.Text;
string strTitle = this.txtTitle.Text;

strText = this.ReplayEmpty(strText);
strText = strText.Replace("\r\n", "</P><P>");
strText = "<P>" + strText;
strText = strText + "</P>";

//保存
string strSQL = string.Empty;

strSQL = "Insert Into TblNews(SortID,CatalogName,AddTime,NewsContent,NewsTitle) Values (";
strSQL += "'{0}','{1}','{2}','{3}','{4}')";
strSQL = string.Format(strSQL, new object[] {
strHeadID, strCataID, dtDateTime, strText,strTitle });

if (this.m_dbChunnel.RunDDLSql(strSQL) > 0)
{
}
else
{
Response.Write("数据保存失败,请重新再试!");
}
}
private string ReplayEmpty(string strText)
{
string str = string.Empty;

int i;
bool bReplayFlag = true;
for (i = 0; i < strText.Length; i++)
{
if (strText.Substring(i, 1) == "<")
{
bReplayFlag = false;
}

if (strText.Substring(i, 1) == ">")
{
bReplayFlag = true;
}

if (bReplayFlag && strText.Substring(i, 1) == " ")
{//替换
str += "  ";
}
else
{
str += strText.Substring(i, 1);
}
}
return str;
}
希望实现存入图片的功能,还有上面只是保存,如何写修改的呢,等待高手!
...全文

相关推荐

评论 17
收藏 已收藏
分享
返回顶部
qyulang
C# 111,128 成员 642,537 内容