codice:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ObjConnection As OleDbConnection
Dim ObjCommand As OleDbCommand
Dim StrConn As String
Dim Query As String
Dim RispUtente As Integer
Try
StrConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Progetto Carrara\Carrara\Carrara\DbCarrara.accdb;"
ObjConnection = New OleDbConnection(StrConn)
ObjConnection.Open()
ObjCommand = New OleDbCommand("INSERT INTO Cliente(Cognome,Nome,Indirizzo,Comune,Telefono,Cellulare,[Cognome Defunto],[Nome Defunto],[DN defunto],[DM defunto],[Zona interrato],[Posizione Nro]) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", ObjConnection)
ObjCommand.Parameters.Add("@Cognome", OleDbType.Char, 50).Value = Me.TextBox1.Text
ObjCommand.Parameters.Add("@Nome", OleDbType.Char, 50).Value = Me.TextBox2.Text
ObjCommand.Parameters.Add("@Indirizzo", OleDbType.Char, 50).Value = Me.TextBox3.Text
ObjCommand.Parameters.Add("@Comune", OleDbType.Char, 50).Value = Me.TextBox4.Text
ObjCommand.Parameters.Add("@Telefono", OleDbType.Char, 50).Value = Me.TextBox5.Text
ObjCommand.Parameters.Add("@Cellulare", OleDbType.Char, 50).Value = Me.TextBox6.Text
ObjCommand.Parameters.Add("@Cognome Defunto", OleDbType.Char, 50).Value = Me.TextBox7.Text
ObjCommand.Parameters.Add("@Nome Defunto", OleDbType.Char, 50).Value = Me.TextBox8.Text
ObjCommand.Parameters.Add("@DN defunto", OleDbType.Date).Value = Me.TextBox9.Text
ObjCommand.Parameters.Add("@DM defunto", OleDbType.Date).Value = Me.TextBox10.Text
ObjCommand.Parameters.Add("@Zona Interrato", OleDbType.Char, 50).Value = Me.TextBox11.Text
ObjCommand.Parameters.Add("@Posizione Nro", OleDbType.Integer, 50).Value = Me.TextBox12.Text
RispUtente = ObjCommand.ExecuteNonQuery()
' If (RispUtente = 1) Then
'MsgBox("inserimento effettuato")
'ObjConnection.Close()
'Me.TextBox1.Text = ""
' Me.TextBox2.Text = ""
' Me.TextBox1.Focus()
' Else
' MsgBox("Inserimento non Effettuato.Rinserisci i dati")
'ObjConnection.Close()
' End If
MsgBox("riusciuto")
Catch ex As Exception
MsgBox("non riusciuto")
ObjConnection.Close()
End Try
Form2.Show()
ObjConnection.Close()
End Sub
End Class
Un'altra cosa il database creato in access metto come tipo di dato Testo....a quale corrisponde in OledbType?ho fatto bene cosi?