icyer()老大和各位高手,我该怎么做那???

baitianhai 2002-06-05 04:17:38
datagrid显示多文档变得一些内容(存有文件),我在下面作了一个文件添加入库的部分,该怎么做那???我这样做添加不进去,分不够的话,我还有
Dim strcon As New String("data source=LONG;initial catalog=sbg;persist security info=False;user id=chb;workstation id=BCH;packet size=4096")
Dim con As New SqlClient.SqlConnection("data source=LONG;initial catalog=sbg;persist security info=False;user id=chb;workstation id=BCH;packet size=4096")
Dim SqlCmd As New String("select * from 多文档信息表 ")
Dim SqlCmd1 As New String("delete from 多文档信息表 where 文档编号=@ImageID ")
Dim sqlcmd2 As New String("INSERT INTO 多文档信息表(文档编号, 文档类型, 文件名称, 创建人,创建日期,文档备注,文档内容) VALUES (@DocuID, @DocuType, @DocuName, @DocuMen,@DocuData,@DocuDemo,@DocuCon)")
Dim com As New SqlClient.SqlCommand(SqlCmd, con)
Dim com1 As New SqlClient.SqlCommand(SqlCmd1, con)
Dim com2 As New SqlClient.SqlCommand(sqlcmd2, con)
'Dim ada As New SqlClient.SqlDataAdapter(SqlCmd, strcon)
Dim ada As New SqlClient.SqlDataAdapter()
Dim dts As New Data.DataSet()
Dim dtv As New Data.DataView()
Protected WithEvents Textbox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Textbox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Textbox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents Textbox4 As System.Web.UI.WebControls.TextBox
#Region " Web 窗体设计器生成的代码 "

'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
ada.SelectCommand = com
ada.DeleteCommand = com1
ada.InsertCommand = com2
con.Open()
ada.Fill(dts, "document")
dtv = dts.Tables("document").DefaultView
DataGrid1.DataSource = dtv
If Not IsPostBack Then
DataGrid1.DataBind()
End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'HttpPostedFile对象,用于读取图象文件属性
Dim UpFile As HttpPostedFile = UP_FILE.PostedFile
'记录文件长度变量
FileLength = UpFile.ContentLength
If UpFile.FileName <> "" Then
Dim StreamObject As System.IO.Stream = UpFile.InputStream
'文件临时储存Byte数组
Dim FileByteArray(FileLength) As Byte
'读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
Dim x = UpFile.FileName.LastIndexOf("\"), File_name = Mid(UpFile.FileName, x + 2)
StreamObject.Read(FileByteArray, 0, FileLength)
Response.Write(FileLength & "<br>")
Response.Write(Textbox1.Text & "<br>")
Response.Write(UpFile.ContentType & "<br>")
Response.Write(File_name & "<br>")
Response.Write(Textbox2.Text & "<br>")
Response.Write(Textbox3.Text & "<br>")
Response.Write(Textbox4.Text & "<br>")
'Response.End()
ada.InsertCommand.Parameters.Add("@DocuID", SqlDbType.Char, 40).Value = Textbox1.Text
ada.InsertCommand.Parameters.Add("@DocuType", SqlDbType.Char, 40).Value = UpFile.ContentType
ada.InsertCommand.Parameters.Add("@DocuName", SqlDbType.Char, 256).Value = File_name
ada.InsertCommand.Parameters.Add("@DocuMen", SqlDbType.Char, 40).Value = Textbox2.Text
ada.InsertCommand.Parameters.Add("@DocuData", SqlDbType.DateTime, FileLength).Value = Textbox3.Text
ada.InsertCommand.Parameters.Add("@DocuDemo", SqlDbType.VarChar, 1000).Value = Textbox4.Text
ada.InsertCommand.Parameters.Add("@DocuCon", SqlDbType.Binary, FileLength).Value = FileByteArray
'Response.Write(ada.InsertCommand.CommandText)
'Response.End()
'com2.Parameters.Add("@Image", SqlDbType.Binary, FileLength).Value = FileByteArray
'com2.Parameters.Add("@ContentType", SqlDbType.VarChar, 50).Value = UpFile.ContentType
'com2.Parameters.Add("@ImageDescription", SqlDbType.VarChar, 200).Value = txtDescription.Text
'com2.Parameters.Add("@ImageSize", SqlDbType.BigInt, 8).Value = UpFile.ContentLength
dtv.AddNew()
ada.Update(dts, "document")
DataGrid1.DataBind()
txtMessage.Text = "<p><b>OK!你已经成功上传你的文件</b>"
Else
txtMessage.Text = "<p><b>请选择正确的文件</b>"
End If
Dim a As New PetroFMClass.Facility()
a.FacilityNo = 1
Dim s = a.GetFacilitiesItemValue("文档编号")
Dim marry() As String = Split(s, ",", -1)
Dim border = UBound(marry), i, sql
sql = "select * from ImageStore where 文档编号='" & marry(0) & "'"
For i = 1 To border
Response.Write(marry(i) & "<br>")
sql = sql & " or 文档编号='" & marry(i) & "'"
Next
Response.Write(sql)
DataGrid1.DataBind()
End Sub
...全文
75 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
yxrj 2002-06-07
  • 打赏
  • 举报
回复
没法让datagrid立刻更新
--- DataGrid1.DataBind()前要重新设置DataSource
baitianhai 2002-06-07
  • 打赏
  • 举报
回复
没人帮忙吗??????????
baitianhai 2002-06-06
  • 打赏
  • 举报
回复
up
baitianhai 2002-06-05
  • 打赏
  • 举报
回复
但是我在这里单独使用command对象就可以添加
不过我没法让datagrid立刻更新 ,应该怎么去写?????

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧