C.N.69
08-06-2009, 19:59
Ciao!!!
Ho sviluppato un'applicazione che permette di interagire con un database creato con access... Fin quando compilo il progetto da visual basic tutto a posto, funziona tutto, perņ quando creo l'installazione e la installo non funziona.
Mi spiego meglio...
Il mio programma prevede la possibilitą di registrare il "cliente" che utilizza l'applicazione. Se l'utente salta la registrazione funziona tutto alla perfezione, se invece cerca di registrarsi si verifica questo errore. Dopo aver premuto il tasto per salvare i dati appare un errore di "overflow".
Vi posto il codice sperando di risolvere il problema:
Imports System.Data.OleDb
Public Class Form1
Dim miaconnessione As OleDbConnection
Dim miocomando As OleDbCommand
Dim dr As OleDbDataReader
Dim bnd As BindingSource
Dim query As String
Dim data As String
Dim ok As Boolean
Dim NR As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
miaconnessione = New OleDbConnection
miocomando = New OleDbCommand
bnd = New BindingSource
ok = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
miaconnessione = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & My.Computer.FileSystem.CurrentDirectory & "\Progetto.mdb; persist security info=false")
If TextBox7.Text = 1 Or TextBox7.Text = 3 Or TextBox7.Text = 5 Or TextBox7.Text = 7 Or TextBox7.Text = 8 Or TextBox7.Text = 10 Or TextBox7.Text = 12 Then
If TextBox6.Text > 0 And TextBox6.Text < 32 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If TextBox7.Text = 4 Or TextBox7.Text = 6 Or TextBox7.Text = 9 Or TextBox7.Text = 11 Then
If TextBox6.Text > 0 And TextBox6.Text < 31 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If TextBox7.Text = 2 Then
If TextBox6.Text > 0 And TextBox6.Text < 29 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If ok = True Then
data = TextBox6.Text + "/" + TextBox7.Text + "/" + TextBox8.Text
If (TextBox1.Text = "") Or (TextBox2.Text = "") Or (TextBox3.Text = "") Or (TextBox4.Text = "") Or (TextBox5.Text = "") Or (TextBox6.Text = "") Then
MsgBox("Se premi avanti devi inserire i tuoi dati", MsgBoxStyle.Critical)
ElseIf IsNumeric(TextBox3.Text) = False Then
MsgBox("Il campo telefono deve essere numerico", MsgBoxStyle.Critical)
Else
miaconnessione.Open()
query = "INSERT INTO clienti (nome_cli, cognome_cli, tel_cli, citta, indirizzo, data_nasc) VALUES (""" + TextBox1.Text + """, """ + TextBox2.Text + """,""" + TextBox3.Text + """,""" + TextBox4.Text + """, """ + TextBox5.Text + """, """ + data + """)"
miocomando = New OleDbCommand(query, miaconnessione)
NR = miocomando.ExecuteNonQuery()
miaconnessione.Close()
Me.Hide()
Form2.Show()
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub TextBox6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox6.Click
TextBox6.Text = ""
End Sub
Private Sub TextBox7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox7.Click
TextBox7.Text = ""
End Sub
Private Sub TextBox8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.Click
TextBox8.Text = ""
End Sub
End Class
Ho sviluppato un'applicazione che permette di interagire con un database creato con access... Fin quando compilo il progetto da visual basic tutto a posto, funziona tutto, perņ quando creo l'installazione e la installo non funziona.
Mi spiego meglio...
Il mio programma prevede la possibilitą di registrare il "cliente" che utilizza l'applicazione. Se l'utente salta la registrazione funziona tutto alla perfezione, se invece cerca di registrarsi si verifica questo errore. Dopo aver premuto il tasto per salvare i dati appare un errore di "overflow".
Vi posto il codice sperando di risolvere il problema:
Imports System.Data.OleDb
Public Class Form1
Dim miaconnessione As OleDbConnection
Dim miocomando As OleDbCommand
Dim dr As OleDbDataReader
Dim bnd As BindingSource
Dim query As String
Dim data As String
Dim ok As Boolean
Dim NR As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
miaconnessione = New OleDbConnection
miocomando = New OleDbCommand
bnd = New BindingSource
ok = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
miaconnessione = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" & My.Computer.FileSystem.CurrentDirectory & "\Progetto.mdb; persist security info=false")
If TextBox7.Text = 1 Or TextBox7.Text = 3 Or TextBox7.Text = 5 Or TextBox7.Text = 7 Or TextBox7.Text = 8 Or TextBox7.Text = 10 Or TextBox7.Text = 12 Then
If TextBox6.Text > 0 And TextBox6.Text < 32 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If TextBox7.Text = 4 Or TextBox7.Text = 6 Or TextBox7.Text = 9 Or TextBox7.Text = 11 Then
If TextBox6.Text > 0 And TextBox6.Text < 31 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If TextBox7.Text = 2 Then
If TextBox6.Text > 0 And TextBox6.Text < 29 Then
ok = True
Else
MsgBox("La data inserita non č corretta", MsgBoxStyle.Information)
End If
End If
If ok = True Then
data = TextBox6.Text + "/" + TextBox7.Text + "/" + TextBox8.Text
If (TextBox1.Text = "") Or (TextBox2.Text = "") Or (TextBox3.Text = "") Or (TextBox4.Text = "") Or (TextBox5.Text = "") Or (TextBox6.Text = "") Then
MsgBox("Se premi avanti devi inserire i tuoi dati", MsgBoxStyle.Critical)
ElseIf IsNumeric(TextBox3.Text) = False Then
MsgBox("Il campo telefono deve essere numerico", MsgBoxStyle.Critical)
Else
miaconnessione.Open()
query = "INSERT INTO clienti (nome_cli, cognome_cli, tel_cli, citta, indirizzo, data_nasc) VALUES (""" + TextBox1.Text + """, """ + TextBox2.Text + """,""" + TextBox3.Text + """,""" + TextBox4.Text + """, """ + TextBox5.Text + """, """ + data + """)"
miocomando = New OleDbCommand(query, miaconnessione)
NR = miocomando.ExecuteNonQuery()
miaconnessione.Close()
Me.Hide()
Form2.Show()
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Hide()
Form2.Show()
End Sub
Private Sub TextBox6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox6.Click
TextBox6.Text = ""
End Sub
Private Sub TextBox7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox7.Click
TextBox7.Text = ""
End Sub
Private Sub TextBox8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox8.Click
TextBox8.Text = ""
End Sub
End Class