Private Sub Command1_Click()
Dim conn1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim rs1 As New ADODB.Recordset
Dim p As Integer
Dim accessconnect, n, a, num, ty As String
accessconnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=POOJA-D4FD585E2\SQL2000"
conn1.ConnectionString = accessconnect
conn1.Open
n = Text1.Text
a = Text2.Text
p = Val(Text3.Text)
num = Text4.Text
ty = Text5.Text
cmd1.ActiveConnection = conn1
cmd1.CommandText = " insert into customer(customer_name,customer_address,customer_phn,cutomer_dob,account_number,account_type) values(' " & n & " ' , ' " & a & " ',' " & p & " ' , ' " & DTPicker1.Value & " ',' " & num & " ' , ' " & ty & " ')"
Set rs1 = cmd1.Execute
conn1.Close
MsgBox ("DATABASE UPDATED SUCCESSFULLY")
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
n = Text1.Text
If n = (" ") And (Len(n) < 3) Then
MsgBox ("Enter valid customer name")
End If
End Sub
Private Sub Text2_Validate(Cancel As Boolean)
a = Text2.Text
If a = (" ") And (Len(a) < 3) Then
MsgBox ("Enter valid address")
End If
End Sub
Private Sub Text3_Validate(Cancel As Boolean)
p = Val(Text3.Text)
If Not IsNumeric(p) And p = (" ") And (Len(p) < 10) Then
MsgBox "Please enter numbers only."
End If
End Sub
Private Sub Text4_Validate(Cancel As Boolean)
num = Text4.Text
If num = (" ") Then
MsgBox ("Account number cannot be null ")
End If
End Sub
Private Sub Text5_Validate(Cancel As Boolean)
ty = Text5.Text
If ty = (" ") Then
MsgBox ("Enter a type of account ")
End If
End Sub
I am a beginner so I am not able to figure it out what is the error this code is not able to validate

New Topic/Question
Reply



MultiQuote





|