Salve, ho un problema con l'inserimento all'intrno di un database sql server attraverso una mascgerina di vb, questo è il codice da me elaborato, ma nn succede niente qulcuno s a aiutarmi? grazie
il Db risiede in locale e ha il nome di esame
Imports System.Data.SqlClient
Imports System.Data
Public Class Giuseppe
Private Sub selectButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles selButton.Click
unoCheckBox.Checked = True
dueCheckBox.Checked = True
treCheckBox.Checked = True
End Sub
Private Sub delButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles delButton.Click
unoCheckBox.Checked = False
dueCheckBox.Checked = False
treCheckBox.Checked = False
End Sub
Private connection As SqlConnection
Protected Sub inviaButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles inviaButton.Click
Dim command As New SqlCommand
command.Connection() = connection
Dim flag As String
Dim flag1 As String
Dim flag2 As String
If unoCheckBox.Checked Then
flag = "N"
Else : flag = "S"
End If
If dueCheckBox.Checked Then
flag1 = "N"
Else : flag1 = "S"
End If
If treCheckBox.Checked Then
flag2 = "N"
Else : flag2 = "S"
End If
command.CommandText() = "INSERT INTO esame (Nome,Cognome,Esame1,Esame2,Esame3,Sostenuto1,Sost enuto2,Sostenuto3) values ('" + nomeTextBox.Text + "','" + TextBox1.Text + "','" + esame1TextBox.Text + "','" + esame2TextBox.Text + "','" + esame3TextBox.Text + "','" + flag + "','" + flag1 + "','" + flag2 + "')"
MessageBox.Show("Registrazione effettuata con uccesso.")
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
connection = New SqlConnection
Dim connectionString As String = "Data Source=ADMIN-09F708620\sqlexpress; Initial Catalog=esami;"
connection.ConnectionString() = connectionString
connection.Open()
Catch
MessageBox.Show(Err.Description)
End Try End Sub
End Class
grazie