[ MarkoBalkan @ 17.09.2008. 20:02 ] @
imam ovaj code, međutim ne ubacuje mi dokument u bazu, u čemu je fora? Code: Imports MySql.Data.MySqlClient Imports System.IO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim conn As New MySqlConnection Dim cmd As New MySqlCommand Dim SQL As String Dim FileSize As UInt32 Dim rawData() As Byte Dim fs As FileStream conn.ConnectionString = "server=127.0.0.1;uid=root;pwd=;database=proba" Try fs = New FileStream("c:\a.pdf", FileMode.Open, FileAccess.Read) FileSize = fs.Length rawData = New Byte(FileSize) {} fs.Read(rawData, 0, FileSize) fs.Close() conn.Open() SQL = "INSERT INTO proba(ID,DOC) VALUES(1,@Filename)" cmd.Connection = conn cmd.CommandText = SQL cmd.CommandType = CommandType.Text cmd.Parameters.AddWithValue("@FileName", rawData) cmd.ExecuteNonQuery() MessageBox.Show("File Inserted into database successfully!", _ "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) conn.Close() Catch ex As Exception MessageBox.Show("There was an error: " & ex.Message, "Error", _ MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class |