Create Stored Procedure
‘We wanna catch errors
Try
   ‘Defining the server and database we wan’t to use
   Dim connect_string As String = “server=” & server_ip & “;uid=” & user_id & “;pwd=” & password & “;database=” & database
   ‘Creating a SQL-connection to the server
   Dim db_connection As New SqlConnection(connect_string)
   ‘Creating a SQL-command
   Dim sql_command As New SqlCommand
   ‘Adding the SQL-connection to the SQL-command
   sql_command.Connection = db_connection
   ‘Adding commandtext to the SQL-command
   sql_command.CommandText = _
“CREATE PROCEDURE dbo.spInsertImages ” & _
” @imageName VARCHAR(150),” & _
” @imageAttr int,” & _
” @imageLastAccessTime datetime,” & _
” @imageLastWriteTime datetime,” & _
” @imageExtension varchar(5),” & _
” @imageCreationTime datetime,” & _
” @imageDirectory varchar(500),” & _
” @imageFullName varchar(650),” & _
” @imageLength int ” & _
” AS ” & _
“INSERT INTO tblImages ” & _
      “(imageName, imageAttr, imageLastAccessTime, imageLastWriteTime, ” & _
      “imageExtension, imageCreationTime, imageDirectory, ” & _
      “imageFullName, imageLength) VALUES (” & _
      “@imagename, ” & _
      “@imageAttr, ” & _
      “@imageLastAccessTime, ” & _
      “@imageLastWriteTime, ” & _
      “@imageExtension, ” & _
      “@imageCreationTime, ” & _
      “@imageDirectory, ” & _
      “@imageFullName, ” & _
      “@imageLength) ”
   ‘Opening the connection to the database
   db_connection.Open()
   ‘Executing the SQL-command
   sql_command.ExecuteNonQuery()
   ‘Closing the connection to the database
   db_connection.Close()
   ‘Cleaning up
   db_connection = Nothing
   connect_string = Nothing
   sql_command = Nothing
   ‘Returning true to the caller if successfull
   Return True
Catch ex As Exception
   ‘Throwing the exception to the caller if something went wrong
   Throw ex
End Try