如何将捕获的照片从相机保存到SQL服务器。 [英] How do I save the captured photo from camera into SQL server.

查看:71
本文介绍了如何将捕获的照片从相机保存到SQL服务器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表的列图片,我将其DataType设置为IMAGE。

但是发生错误从对象类型System.Windows.Forms.PictureBox到已知的托管提供者本机没有映射类型。我该如何解决这个问题?谢谢



我尝试过:



I have a table's column "Pictures" and I set its DataType as IMAGE.
But error occurs "No mapping exist from object type System.Windows.Forms.PictureBox to a known managed provider native type". How do I fix this problem? Thanks

What I have tried:

Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        Dim cmd As New SqlCommand
        Try
            conn.ConnectionString = strcon
            conn.Open()
            cmd.Connection = conn
            cmd.CommandText = "INSERT INTO PatientInfo (Surname,Firstname,MI,Gender,Birthday,Address,Contact,Email, Picture) VALUES(@Surname,@Firstname,@MI,@Gender,@Birthday,@Address,@Contact,@Email,@Photo)"

            cmd.Parameters.AddWithValue("@Surname", txtSurname.Text)
            cmd.Parameters.AddWithValue("@Firstname", txtFirstname.Text)
            cmd.Parameters.AddWithValue("@MI", txtMI.Text)
            cmd.Parameters.AddWithValue("@Gender", CmbxGender.Text)
            cmd.Parameters.AddWithValue("@Birthday", dtpBday.Text)
            cmd.Parameters.AddWithValue("@Address", txtAdd.Text)
            cmd.Parameters.AddWithValue("@Contact", txtContact.Text)
            cmd.Parameters.AddWithValue("@Email", txtEmail.Text)
            cmd.Parameters.AddWithValue("@Photo", picbx2x2)
            cmd.ExecuteNonQuery()
            MessageBox.Show("Successful Added Data")
            loadData()
            conn.Dispose()
            conn.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try



    End Sub

推荐答案

如上所示,图片作为blob存储在SQL服务器中。



比保存正常字段通知要多一些a / b


请参阅以下链接作为搜索google将blob保存到sql的示例。互联网上有很多例子



< a href > http://www.akadia.com/services/dotnet_read_write_blob.html [ ^ ]
As indicated above pictures are stored in a SQL server as a blob.

Its a bit more involved than saving normal field information.

See the following link as an example for search google for saving blob into sql. There are plenty of examples on the internet

<a href">http://www.akadia.com/services/dotnet_read_write_blob.html[^]


这篇关于如何将捕获的照片从相机保存到SQL服务器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆