'Please attach the database to your SQL Server 2000 Database first.
Public pubCnn As New OleDb.OleDbConnection
Public strCnn As String = "Provider=SQLOLEDB.1; Data Source=.; " & _
" Initial Catalog=SCHOOLSTAT; User ID=sa; Password=;"
'insert data to table
Dim cmd As New OleDb.OleDbCommand
Dim arrImage As Byte()
Dim myMS As New IO.MemoryStream
Dim strImage As String = ""
If Not IsNothing(Me.picPhoto.Image) Then
Me.picPhoto.Image.Save(myMS, Me.picPhoto.Image.RawFormat)
arrImage = myMS.GetBuffer
strImage = "?"
Else
arrImage = Nothing
strImage = "NULL"
End If
--------------
cmd.Connection = pubCnn
If Me.id = 0 Then
id = GetSchoolID()
cmd.CommandText = "INSERT INTO school(id, schoolcode, name" & _
",provinceid,phone,type, photo) " & _
" VALUES(" & id & "," & SQLString(Me.txtSchoolCode.Text) & _
"," & SQLString(Me.txtSchoolName.Text) & _
"," & prID & "," & _
SQLString(Me.txtPhone.Text) & "," & schtype & _
"," & strImage & ")"
If strImage <> "NULL" Then
Dim cmdPar As New OleDb.OleDbParameter
cmdPar = cmd.Parameters.Add("?", OleDb.OleDbType.Binary)
cmdPar.Value = arrImage
End If
Download Source Code and Database Here
Thursday, June 24, 2010
Using Khmer Unicode and Save Image to SQL Server in VB 2008
Subscribe to:
Post Comments (Atom)
4 comments:
I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.
interesting blog. It would be great if you can provide more details about it. Thanks you
Web Development
Thanks for useful tips.
Asp.net Development
Thanks for the useful tips
Post a Comment