English 中文(简体)
ql服务器的库存形象
原标题:Store image in sql server

我的守则是:

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim myfilelocation As String = "C:myPicturesmyimage.png"
        Dim conn As New SqlConnection("Data Source=MUSTAFAMUSTAFA;Initial Catalog=Tijaabo;User ID=sa;Password=123")
        Dim cmd As New SqlCommand("insert into customers(CustomerID,fname) Values( " & CustomerIDTextBox.Text & " , " & FnameTextBox.Text & " )", conn)

        Dim cmd1 As New SqlCommand("update customers set photo = @picturebox where CustomerID=" + CustomerIDTextBox.Text, conn)

Dim param As New SqlParameter("@picturebox", SqlDbType.VarBinary) 

        Dim ImageData As Byte() = IO.File.ReadAllBytes(myfilelocation)
        param.Value = ImageData
        cmd.Parameters.Add(param)

        cmd.Parameters.AddWithValue("@CustomerID", 3)
        Try
            conn.Open()
            cmd.ExecuteNonQuery()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        Finally
            conn.Close()
        End Try

    End Sub

------------------------------------------------------------------------------------------

我的问题是:

  1. 由于申请在数据库中储存,我如何能够将该守则检索到门槛值中,因为我可以将其输入数据库?

  2. 你们可以看到,图像正从我的机器中找到其位置,因为我要么想把它放在能够获取图像的其他计算机的某个地方,要么告诉其他电脑,把图像储存在我的机器中,然后从这里检索。

问题回答

我认为,你的目的是在数据库中储存图像,因此没有必要将其储存在网络中或使你的电脑能够使用。

照片没有输入数据库,因为你没有操作<编码>cmd1的指令。





相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签