- Imports System.Data.OleDb
-
Imports System.Data.SqlClient
-
-
Public Class Form2
-
Public connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\REORBETA\Desktop\COPRO VB NET PROGRAM FINALS\VB NET Database\Database\Database\Database.accdb"
-
Public conn As New OleDbConnection
-
-
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
-
'TODO: This line of code loads data into the 'DatabaseDataSet.Status' table. You can move, or remove it, as needed.
-
Me.StatusTableAdapter.Fill(Me.DatabaseDataSet.Status)
-
'TODO: This line of code loads data into the 'DatabaseDataSet.View_Instructors' table. You can move, or remove it, as needed.
-
Me.View_InstructorsTableAdapter.Fill(Me.DatabaseDataSet.View_Instructors)
-
'TODO: This line of code loads data into the 'DatabaseDataSet.View_Courses' table. You can move, or remove it, as needed.
-
Me.View_CoursesTableAdapter.Fill(Me.DatabaseDataSet.View_Courses)
-
'TODO: This line of code loads data into the 'DatabaseDataSet.Status_Year_Level_and_Program' table. You can move, or remove it, as needed.
-
Me.Status_Year_Level_and_ProgramTableAdapter.Fill(Me.DatabaseDataSet.Status_Year_Level_and_Program)
-
'TODO: This line of code loads data into the 'DatabaseDataSet.Student_Registration' table. You can move, or remove it, as needed.
-
Me.Student_RegistrationTableAdapter.Fill(Me.DatabaseDataSet.Student_Registration)
-
-
conn.ConnectionString = connstring
-
-
'to test if the connection to the database is open
-
If conn.State = ConnectionState.Closed Then
-
conn.Open()
-
MsgBox("Database connection is now open")
-
Else
-
MsgBox("Database Connection has been Closed")
-
End If
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
-
Dim clsValidate As New ValidateTextBox
-
-
'validating empty txtID
-
If clsValidate.IsTextBoxEmpty(txtID) = True Then
-
MessageBox.Show("Please enter ID")
-
Exit Sub
-
End If
-
-
'validating a numeric input for ID
-
If clsValidate.IsTextBoxNumeric(txtID) = False Then
-
MessageBox.Show("Please enter a valid ID")
-
Exit Sub
-
End If
-
-
'validating the an empty textLName
-
If clsValidate.IsTextBoxEmpty(txtLName) Then
-
MessageBox.Show("Please enter First Name")
-
Exit Sub
-
End If
-
-
'validating a character input for LastName
-
If clsValidate.IsTextBoxNumeric(txtLName) = True Then
-
MessageBox.Show("Please enter a valid First Name")
-
Exit Sub
-
End If
-
-
'validating the an empty textFName
-
If clsValidate.IsTextBoxEmpty(txtFName) Then
-
MessageBox.Show("Please enter First Name")
-
Exit Sub
-
End If
-
-
'validating a character input for FirstName
-
If clsValidate.IsTextBoxNumeric(txtFName) = True Then
-
MessageBox.Show("Please enter a valid First Name")
-
Exit Sub
-
End If
-
-
'validating the an empty textMName
-
If clsValidate.IsTextBoxEmpty(txtMName) Then
-
MessageBox.Show("Please enter Middle Name")
-
Exit Sub
-
End If
-
-
'validating a character input for MiddleName
-
If clsValidate.IsTextBoxNumeric(txtMName) = True Then
-
MessageBox.Show("Please enter a valid Middle Name")
-
Exit Sub
-
End If
-
-
'validating empty txtContact1
-
If clsValidate.IsTextBoxEmpty(txtContact1) = True Then
-
MessageBox.Show("Please enter Contact Number")
-
Exit Sub
-
End If
-
-
'validating a numeric input for txtContact1
-
If clsValidate.IsTextBoxNumeric(txtContact1) = False Then
-
MessageBox.Show("Please enter a valid Contact Number")
-
Exit Sub
-
End If
-
-
'validating the an empty txtAddress
-
If clsValidate.IsTextBoxEmpty(txtAddress) Then
-
MessageBox.Show("Please enter Address")
-
Exit Sub
-
End If
-
-
'validating a character input for txtAddress
-
If clsValidate.IsTextBoxNumeric(txtAddress) = True Then
-
MessageBox.Show("Please enter a valid Address")
-
Exit Sub
-
End If
-
-
'validating the an empty txtGuardian
-
If clsValidate.IsTextBoxEmpty(txtGuardian) Then
-
MessageBox.Show("Please enter Guardian Name")
-
Exit Sub
-
End If
-
-
'validating a character input for Guardian
-
If clsValidate.IsTextBoxNumeric(txtGuardian) = True Then
-
MessageBox.Show("Please enter a valid Guardian Name")
-
Exit Sub
-
End If
-
-
'validating empty txtContact2
-
If clsValidate.IsTextBoxEmpty(txtContact2) = True Then
-
MessageBox.Show("Please enter Contact Number")
-
Exit Sub
-
End If
-
-
'validating a numeric input for txtContact2
-
If clsValidate.IsTextBoxNumeric(txtContact2) = False Then
-
MessageBox.Show("Please enter a valid Contact Number")
-
Exit Sub
-
End If
-
-
'inserting the new record to database
-
Try
-
Dim SqlQuery As String = "INSERT INTO Friends (ID, Last Name, First Name, Middle Name, Contact Number, Address, Guardian, Contact Number) VALUES ('" & txtID.Text & "','" & txtLName.Text & "','" & txtFName.Text & "','" & txtMName.Text & "','" & txtContact1.Text & "','" & txtAddress.Text & "','" & txtGuardian.Text & "','" & txtContact2.Text & "')"
-
Dim SqlCommand As New OleDbCommand
-
-
With SqlCommand
-
.CommandText = SqlQuery
-
.Connection = conn
-
.ExecuteNonQuery()
-
End With
-
MsgBox("Record Succesfully Added")
-
-
'refreshing the textbox for new record
-
txtID.Text = ""
-
txtLName.Text = ""
-
txtFName.Text = ""
-
txtMName.Text = ""
-
txtContact1.Text = ""
-
txtAddress.Text = ""
-
txtGuardian.Text = ""
-
txtContact2.Text = ""
-
-
Catch ex As Exception
-
MsgBox(ex.Message)
-
End Try
-
-
End Sub
-
End Class
4 1284
We were told to make a project that uses database, We are using VB.NET with either SQL or using MS Access, I used Access on mine since it was troublesome download since its time consuming and I have Access ready in my PC.
Having trouble with this, please help oh great programmers hehe!
pod 298
Contributor
I'll go out o a limb here and say that this is the first run at it, am I right?
If so then I suggest to use small steps:
first step,connect to the database, and display a message depending if successful or not.
Test it!
When this succeeds, add another step; get a record from a table and show the result in a message.
Test it!
... and so forth.
If this is not your first run and you were progressing well until you added the "ValidateTextBox" call then the message is telling you what is wrong, ... ValidateTextBox is not defined ... in your code a least.
If you took this portion of the code from some other project, you only got part of it; go back and look for the class named "ValidateTextBox" with its two functions; IsTextBoxEmpty, IsTextBoxNumeric ... or write your own class (the latter would be a better learning experience ;)
Good luck
P:oD
I did test the connection to the database and it was successful. Yes, I did take this portion of validation from our three previous exercises but there were no class ValidateTextBox declared but it executes well and there were no error. Im confused with what's happening to my project, hahaha, in all four forms, the only errors I got was the same error which is "ValidateTextBox is not defined", Thank you for the reply, I will try to declare class name ValidateTextBox, I hope it will work. :)
Rabbit 12,516
Recognized Expert Moderator MVP
ValidateTextBox looks like some sort of third party control. But I don't see that you bring in the third party code anywhere.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: camaro77 majau via DotNetMonster.com |
last post by:
Sorry by my english but i'm from spain.
I have a problem and after search by the web i have know that is due by
framework.
The message is : setup error "failed to load ressouces from resource...
|
by: Joseph McConaughey |
last post by:
Hello All,
I have been working on .NET (especially C#) applications on this computer
for a long time. Everything was working fine until yesterday, but when I came
back into work today and tried...
|
by: VB Programmer |
last post by:
I am using the free rich text editor control from ExportTechnologies. Every
once in a while I get this error (for no apparent reason). Sometimes it
happens even when I'm working on a totally...
|
by: Sean Carey |
last post by:
I converted a C# Upload app to VB.NET and am down to one error and was
hoping someone could help me with te error. I would greatly appreciate
help from anyone.
Here is the error:
...
|
by: drew.ferraro |
last post by:
Hi,
I am trying to build a .DLL file that uses
"'Microsoft.ApplicationBlocks.ExceptionManagement.Interfaces'". I am
trying to build this .DLL as fully signed. However, when I try to
build, I...
| |
by: EMMAY |
last post by:
Hi guys,
I'm building a MFC extension dll using c++.net 2003. everything was fine before I add the flag AFX_EXT_CLASS to a managed class. but once add this flag, as following:
__gc class...
|
by: imranabdulaziz |
last post by:
Dear All,
I am making web application using Asp.net C#(Visual Studio2005). And Sql server 2005 as a back End
I generated local mode report but as there was no printing option available . I assign...
|
by: Debbie |
last post by:
I wonder if anyone can help me out, or point me in the right direction, in
solving my current problem:
I have started seeing an error on one of my ASP pages. Id displays totally
blank except...
|
by: Alan Silver |
last post by:
Hello,
I'm a newbie at PHP and MySql, although I have wads of experience of
ASP, ASP.NET, SQL Server, etc.
I have just installed PHP 5.2.3 on a server (Windows Server 2003), as
well as MySql...
|
by: ramyamoparthi |
last post by:
<%@ page import="java.sql.*"%>
<jsp:include page="home.jsp" />
<div style="left:200;top:0;height:100%;width:800;background-color:#d6d6d6;position:absolute">
<HTML>
<HEAD>
<TITLE> Add B.Tech...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |