Questa è l'equivalente query con SQLServer che scrive un testo nellatabella 'MiaTabella' passando alla funzione il parametro 'testo'.
codice:
Function WriteTesto(ByVal testo As String) As Boolean
Dim objConnection As New SqlConnection("server=MioServer;database=MioDb;user=MioUser;password=MiaPassword;Timeout=10")
Dim objcommand As New SqlCommand
objcommand.Connection = objConnection
objcommand.CommandType = CommandType.Text
objcommand.Parameters.AddWithValue("@testo", testo)
objcommand.Parameters.AddWithValue("@time", DateTime.Now)
objcommand.CommandText = "INSERT INTO MiaTabella (Question,Time) VALUES (@testo,@time)"
Try
objConnection.Open()
Dim esito As Boolean = objcommand.ExecuteNonQuery()
objConnection.Close()
Return esito
Catch ex As Exception
End Try
End Function