In this example, I have a page with a FileUpload component and a button. Paste the following code into the button_click event or write a seperate function to call:
Dim myConnection As New MySql.Data.MySqlClient.MySqlConnection
myConnection.ConnectionString = "Server=MYSERVER;User Id=MYUSER;Password=MYPASS;Persist Security Info=True;Database=MYDATABASE"
myConnection.Open()
Dim mycommand As New MySql.Data.MySqlClient.MySqlCommand
mycommand.Connection = myConnection
Dim strsql
strsql = "INSERT INTO `mydb`.`mytable` (`Document` ) VALUES (?file);"
mycommand.Parameters.Add("?file", FileUpload1.FileBytes)
mycommand.CommandText = strsql
mycommand.ExecuteNonQuery()
As usual, fill out the bold text correctly. Easy huh?
No comments:
Post a Comment