现在数据库里只能存文本,我想存入图片,这是存文本的代码
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;
}
希望实现存入图片的功能,还有上面只是保存,如何写修改的呢,等待高手!