Torna al Thread
Public Sub InsertPath(ByVal Path As String)
' Creo l'oggetto connection in Windows Authentication, se volessi la SQL devi rimuovere Integrated Security=SSPI e mettere
' User Id=TUOSQLUSER; Password=TUASQLPASSWORD;.
Dim ObjConn As New SQLConnection("Data Source=TUOSERVER; Initial Catalog=TUODB; Integrated Security=SSPI;")
' apro la connessione
ObjConn.Open()
' Creo il comando che mi servirà per inserire su DB
Dim ObjCmd As New SQLCommand("INSERT INTO TabellaFoto (CampoPercorso) VALUES (@ParametroPercorso)", ObjConn)
' Creo il parametro da passare alla insert
ObjCmd.Parameters.Add("@ParametroPercorso", SqlDbType.VarChar, 255).Value = Path
Try
' Eseguo il comando
ObjCmd.ExecuteNonQuery()
Catch ex As Exception
Response.Write(ex.Message)
Finally
' disalloco
ObjCmd.Dispose()
ObjConn.Close()
ObjConn.Dispose()
End Try
End Sub