English 中文(简体)
如何拯救双向档案以数据库
原标题:how to save binary file to database

Join Date: Dec 10 Posts: 10 caba11 is an unknown quantity at this point (<10)

how to save binary file to database hi. i need to save files into database... i cant find why it is not working...

这是我的法典:

Public Sub importfiles(ByVal sFileName As String)

    Dim cnSQL As SqlConnection
    Dim cmSQL As SqlCommand
    Dim strSQL

     Validate form values

     Read file into a stream
    Dim fs As New FileStream(sFileName, FileMode.Open, FileAccess.Read)
    Dim myData(fs.Length) As Byte
    fs.Read(myData, 0, fs.Length)
    fs.Close()

    Try

         Build  SQL
        strSQL = "insert into data_cesta(ID, cesta) values (@ID, @cesta)"

        cnSQL = New SqlConnection("Data Source=.;AttachDbFilename=|DataDirectory|Database1.mdf;Integrated Security=True;User Instance=True")
        cmSQL = New SqlCommand(strSQL, cnSQL)

    cmSQL.Parameters.Add(New SqlParameter("@ID", SqlDbType.Int)).Value = ID
    cmSQL.Parameters.Add(New SqlParameter("@cesta", SqlDbType.NText)).Value = myData
       cmd2.Parameters.Add("@ID", SqlDbType.Int).Value = ID
      cmd2.Parameters.Add("@cesta", SqlDbType.NText).Value = myData


     Open connection and execute the command
    cnSQL.Open()
    cmSQL.ExecuteNonQuery()

     Close and clean up objects
    cnSQL.Close()
    cmSQL.Dispose()
    cnSQL.Dispose()

    Catch ex As SqlException
    MsgBox(ex.Message, MsgBoxStyle.Critical, "SQL Error")
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical, "General Error")
    End Try

End Sub

未经审判,“cmSQL.ExecuteNon Query()”——“Failed,将参数值从数据GridViewTextBoxColumn改为Int32 ”。

最佳回答

在将一些档案带入数据Grid之前,由您负责。

违约时,作为数据GridViewTextBoxColumn标在数据Grid中,你国际发展研究中心被传至程序。 您需要在该物体内检索案文。

您可以通过在正在处理的行文上查阅相关的数据GridViewTextBoxCell物体来做到这一点。 在数据GridViewTextBoxCell物体中,一种称为“Value”的财产,其价值是你所需要的。

如果不看到更多的密码,就很难给你确切的代码,但检查了。 DataGridViewCell Object for some help code,因为文本BoxCell继承了这一类。

问题回答

暂无回答




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签