以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]SQL数据库文件上传下载  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=83275)

--  作者:扶风
--  发布时间:2016/4/5 17:41:00
--  [求助]SQL数据库文件上传下载
老师:
     现在已经连上sql数据库,但我想把文件上传到数据库上以及从数据库里下载到本地,我只知道要转化成二进制来实现,控件用哪一个,具体操作怎么做?
[此贴子已经被作者于2016/4/5 17:41:22编辑过]

--  作者:大红袍
--  发布时间:2016/4/5 17:43:00
--  

 不需要用控件,参考

 

http://www.foxtable.com/help/topics/2954.htm

 


--  作者:扶风
--  发布时间:2016/4/18 16:38:00
--  
Dim dlg As New OpenFileDialog   
Dim lujing = dlg.FileName
Dim ifo As new FileInfo(lujing)
Dim w_CreationTime As String
Dim w_LastWriteTime As String
Dim w_LastAccessTime As String
Dim w_ReadOnly As String
Dim w_Hidden As String
Dim w_Path As String
Dim w_Length As String
Dim w_Name As String
Dim w_Extension As String
Dim w_type As String

Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.C         \'数据库名
conn.Open

Dim sql As String
sql="alter wdjbxxb set id = 4 ,wdmc= w_Name ,wdlx= w_type ,wddx= w_Length  "
rs.Close
conn.Close

老师,我在之前的窗口已获得值,然后我想在最后一个窗口点击保存将之前的数据一起上传至sql中的一行,我这么写报错:路径的形式不合法。请问怎么改

--  作者:大红袍
--  发布时间:2016/4/18 16:41:00
--  

你写的都是什么代码?直接给某行赋值。

 

dr("id") = 4

dr("wdmc") = w_Name


--  作者:扶风
--  发布时间:2016/4/23 13:20:00
--  
老师,现在我在table控件的doubleclick事件中这么写,
If Tables("SQL_wdjbxxb").Current Is Nothing Then      \'SQL_wdjbxxb为外部数据表,内容和数据库的一样
    Return
End If
Dim dr As DataRow = Tables("SQL_wdjbxxb").Current.DataRow
Dim pts As String = dr.SQLGetValue("hzm")              \'hzm为数据库的后缀名一列
Dim lujing As String =  ProjectPath &  dr("wdmc") & "." & pts
If FileSys.FileExists(lujing) Then \'如果本地存在同名文件
    \'则直接使用本地文件
Else \'否则从数据库提取文件
    If dr.SQLLoadFile("image",lujing) = False Then \'如果提取文件失败    ‘image为数据库的二进制一列
        Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Return
    End If
End If
Dim Proc As New Process \'打开文件
Proc.File = lujing
Proc.Start()


图片点击可在新窗口打开查看此主题相关图片如下:截图20160423131745.png
图片点击可在新窗口打开查看
图为table控件的属性  wdjbxxb为数据库表

我双击table里的一行后报错  从类型"DBNull"到类型"String"的转换无效. ,请问老师这是什么问题?

--  作者:Hyphen
--  发布时间:2016/4/23 14:41:00
--  
If Tables("SQL_wdjbxxb").Current Is Nothing Then      \'SQL_wdjbxxb为外部数据表,内容和数据库的一样
    Return
End If
Dim dr As DataRow = Tables("SQL_wdjbxxb").Current.DataRow
Dim pts As String = dr.SQLGetValue("hzm")              \'hzm为数据库的后缀名一列
If dr.IsNull("wdmc") = False Then
    Dim lujing As String =  ProjectPath &  dr("wdmc") & "." & pts
    If FileSys.FileExists(lujing) Then \'如果本地存在同名文件
        \'则直接使用本地文件
    Else \'否则从数据库提取文件
        If dr.SQLLoadFile("image",lujing) = False Then \'如果提取文件失败    \'image为数据库的二进制一列
            Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Return
        End If
    End If
    Dim Proc As New Process \'打开文件
    Proc.File = lujing
    Proc.Start()
End If

--  作者:扶风
--  发布时间:2016/4/23 16:05:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:截图20160423160604.png
图片点击可在新窗口打开查看

还是这样。
[此贴子已经被作者于2016/4/23 16:06:22编辑过]

--  作者:Hyphen
--  发布时间:2016/4/23 16:25:00
--  
If Tables("SQL_wdjbxxb").Current Is Nothing Then      \'SQL_wdjbxxb为外部数据表,内容和数据库的一样
    Return
End If
Dim dr As DataRow = Tables("SQL_wdjbxxb").Current.DataRow
Dim pts As String = dr.SQLGetValue("hzm") .ToString()             \'hzm为数据库的后缀名一列
If dr.IsNull("wdmc") = False Then
    Dim lujing As String =  ProjectPath &  dr("wdmc") & "." & pts
    If FileSys.FileExists(lujing) Then \'如果本地存在同名文件
        \'则直接使用本地文件
    Else \'否则从数据库提取文件
        If dr.SQLLoadFile("image",lujing) = False Then \'如果提取文件失败    \'image为数据库的二进制一列
            Messagebox.Show("附件提取失败,可能并不存在附件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Return
        End If
    End If
    Dim Proc As New Process \'打开文件
    Proc.File = lujing
    Proc.Start()
End If

--  作者:Hyphen
--  发布时间:2016/4/23 16:26:00
--  
bug,已经提交。

先按照上面的方法用,列“hzm”没有内容

--  作者:扶风
--  发布时间:2016/4/23 16:30:00
--  
这次是打开文件了,但为什么点每一行都是打开同一个文件,而且有的行实际是没文件的,他也能打开。请问这是什么情况?