예제 #1
0
    private void InsertRow(string insertFileName, string parentID, string allPath, string path, Stream file, string guid, string type)
    {
        byte[] bytelist = new byte[file.Length];
        file.Read(bytelist, 0, int.Parse(file.Length.ToString()));
        string strsql = String.Format("insert into t_document(NAME,PARENTID,FILEPATH,SORT,TYPE,KEYWORDS,LINK,guid,cFileType) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')", insertFileName, parentID, allPath, "", "1", this.TextBox_KeyWord.Text.Trim(), path, guid, type);


        StringBuilder str = new StringBuilder();

        str.Append(String.Format("insert into t_document(NAME,PARENTID,FILEPATH,SORT,TYPE,KEYWORDS,LINK,guid,cContent) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}',@content)", insertFileName, parentID, allPath, "", "1", this.TextBox_KeyWord.Text.Trim(), path, guid));

        try
        {
            MyDataOp dbdo = new MyDataOp(strsql);
            if (dbdo.ExecuteCommandpara(bytelist, str))
            {
                Response.Write("<script>window.alert('保存文件成功!'); window.location.href ='ExpertTree.aspx';</script>");
                return;
            }
            else
            {
                if (dbdo.ExecuteCommand())
                {
                    Response.Write("<script>window.alert('保存文件成功!'); window.location.href ='ExpertTree.aspx';</script>");
                    return;
                }
                else
                {
                    Response.Write("<script>window.alert('保存文件失败!'); window.location.href ='ExpertTree.aspx';</script></script>");
                    return;
                }
            }
        }
        catch (Exception msg)
        {
        }
        finally
        {
        }
    }