Linking a form VB.Net to SQL Server

fie

Member
Joined
Aug 30, 2005
Messages
22
Programming Experience
1-3
I am new to VB.Net. Please help me
I have an SQL Server recident on my system and I am writing a VB.Net program to link the SQL database called books. I have designed a form with 3 fields and the table called Authors which contain the following 3 fields.

1. Authorid: int
2. Firstname: nvarchar
3. Lastname: nvarchar

Each time I run it it gives me the following message:

An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: The ConnectionString property has not been initialized.

Please find below my codes I don't know what i am missing out.

Thank you for your response.

VB.NET:
Imports System.Data.SqlClient
Imports System.Windows.Forms
PublicClass Authors
Inherits System.Windows.Forms.Form
 
' integer holds the number of records inserted
#Region " Windows Form Designer generated code "
PublicSubNew()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
'open connection
AuthorSqlConnection.Open()
EndSub
'Form overrides dispose to clean up the component list.
ProtectedOverloadsOverridesSub Dispose(ByVal disposing AsBoolean)
If Disposing Then
IfNot (components IsNothing) Then
components.Dispose()
EndIf
EndIf
MyBase.Dispose(Disposing)
EndSub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer. 
'Do not modify it using the code editor.
FriendWithEvents cmdAdd As System.Windows.Forms.Button
FriendWithEvents cmdDelete As System.Windows.Forms.Button
FriendWithEvents lblAuthorid As System.Windows.Forms.Label
FriendWithEvents lblFirstname As System.Windows.Forms.Label
FriendWithEvents lblLastname As System.Windows.Forms.Label
FriendWithEvents txtAuthorid As System.Windows.Forms.TextBox
FriendWithEvents txtFirstname As System.Windows.Forms.TextBox
FriendWithEvents txtlastname As System.Windows.Forms.TextBox
FriendWithEvents lblTitle As System.Windows.Forms.Label
FriendWithEvents AuthorSqlConnection As System.Data.SqlClient.SqlConnection
FriendWithEvents AuthorSqlCommand As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents AuthorSqlDataAdapter As System.Data.SqlClient.SqlDataAdapter
<System.Diagnostics.DebuggerStepThrough()> PrivateSub InitializeComponent()
Me.txtAuthorid = New System.Windows.Forms.TextBox
Me.lblAuthorid = New System.Windows.Forms.Label
Me.lblFirstname = New System.Windows.Forms.Label
Me.txtFirstname = New System.Windows.Forms.TextBox
Me.lblLastname = New System.Windows.Forms.Label
Me.txtlastname = New System.Windows.Forms.TextBox
Me.lblTitle = New System.Windows.Forms.Label
Me.cmdAdd = New System.Windows.Forms.Button
Me.cmdDelete = New System.Windows.Forms.Button
Me.AuthorSqlConnection = New System.Data.SqlClient.SqlConnection
Me.AuthorSqlCommand = New System.Data.SqlClient.SqlCommand
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.AuthorSqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
Me.SuspendLayout()
'
'txtAuthorid
'
Me.txtAuthorid.Location = New System.Drawing.Point(264, 104)
Me.txtAuthorid.Name = "txtAuthorid"
Me.txtAuthorid.TabIndex = 0
Me.txtAuthorid.Text = ""
'
'lblAuthorid
'
Me.lblAuthorid.Location = New System.Drawing.Point(144, 104)
Me.lblAuthorid.Name = "lblAuthorid"
Me.lblAuthorid.TabIndex = 1
Me.lblAuthorid.Text = "AuthorID"
'
'lblFirstname
'
Me.lblFirstname.Location = New System.Drawing.Point(144, 144)
Me.lblFirstname.Name = "lblFirstname"
Me.lblFirstname.TabIndex = 3
Me.lblFirstname.Text = "First Name"
'
'txtFirstname
'
Me.txtFirstname.Location = New System.Drawing.Point(264, 144)
Me.txtFirstname.Name = "txtFirstname"
Me.txtFirstname.Size = New System.Drawing.Size(216, 20)
Me.txtFirstname.TabIndex = 2
Me.txtFirstname.Text = ""
'
'lblLastname
'
Me.lblLastname.Location = New System.Drawing.Point(144, 184)
Me.lblLastname.Name = "lblLastname"
Me.lblLastname.TabIndex = 5
Me.lblLastname.Text = "Last Name"
'
'txtlastname
'
Me.txtlastname.Location = New System.Drawing.Point(264, 184)
Me.txtlastname.Name = "txtlastname"
Me.txtlastname.Size = New System.Drawing.Size(216, 20)
Me.txtlastname.TabIndex = 4
Me.txtlastname.Text = ""
'
'lblTitle
'
Me.lblTitle.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, CType((System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Italic), System.Drawing.FontStyle), System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTitle.ImageAlign = System.Drawing.ContentAlignment.TopCenter
Me.lblTitle.Location = New System.Drawing.Point(200, 24)
Me.lblTitle.Name = "lblTitle"
Me.lblTitle.Size = New System.Drawing.Size(176, 23)
Me.lblTitle.TabIndex = 6
Me.lblTitle.Text = "AUTHORS"
'
'cmdAdd
'
Me.cmdAdd.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdAdd.Location = New System.Drawing.Point(176, 296)
Me.cmdAdd.Name = "cmdAdd"
Me.cmdAdd.Size = New System.Drawing.Size(56, 32)
Me.cmdAdd.TabIndex = 7
Me.cmdAdd.Text = "Add Record"
'
'cmdDelete
'
Me.cmdDelete.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdDelete.Location = New System.Drawing.Point(296, 296)
Me.cmdDelete.Name = "cmdDelete"
Me.cmdDelete.Size = New System.Drawing.Size(80, 32)
Me.cmdDelete.TabIndex = 8
Me.cmdDelete.Text = "Delete Record"
'
'AuthorSqlDataAdapter
'
Me.AuthorSqlDataAdapter.DeleteCommand = Me.SqlDeleteCommand1
Me.AuthorSqlDataAdapter.InsertCommand = Me.SqlInsertCommand1
Me.AuthorSqlDataAdapter.SelectCommand = Me.SqlSelectCommand1
Me.AuthorSqlDataAdapter.UpdateCommand = Me.SqlUpdateCommand1
'
'Authors
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(608, 430)
Me.Controls.Add(Me.cmdDelete)
Me.Controls.Add(Me.cmdAdd)
Me.Controls.Add(Me.lblTitle)
Me.Controls.Add(Me.lblLastname)
Me.Controls.Add(Me.txtlastname)
Me.Controls.Add(Me.lblFirstname)
Me.Controls.Add(Me.txtFirstname)
Me.Controls.Add(Me.lblAuthorid)
Me.Controls.Add(Me.txtAuthorid)
Me.Name = "Authors"
Me.Text = "Authors"
Me.ResumeLayout(False)
EndSub
#EndRegion
 
PrivateSub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
Try
' ensure first and last name input
If (txtAuthorid.Text <> "" AndAlso txtFirstname.Text <> "") Then
' create the SQL query to insert a row
AuthorSqlDataAdapter.InsertCommand.CommandText = _
"INSERT INTO Authors(Authorid, fistname, lastname) VALUES('" & txtAuthorid.Text & "' ,'" & txtFirstname.Text & "' , '" & txtlastname.Text & "')"
' notify the user the query is being sent
'txtStatus.Text &= vbCrLf & "Sending query: " & _
'AddressBookDataAdapter.InsertCommand. _
'CommandText & vbCrLf
' send query
AuthorSqlDataAdapter.InsertCommand.ExecuteNonQuery()
MessageBox.Show("Record Created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
AuthorSqlConnection.Close()
' prompt user to input first and last name
Else
MessageBox.Show("Enter at least Agent Description and Agent Branch then press Add Record", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
EndIf
' display verbose information when database exception
Catch oleDbExceptionParameter As _
System.Data.sqlclient.SqlException
Console.WriteLine(oleDbExceptionParameter.StackTrace)
'txtStatus.Text &= oleDbExceptionParameter.ToString
EndTry
EndSub' cmdAdd_Click
EndClass
 
Last edited by a moderator:
Hey John,

As the error states, the SQLConnection object is never initialised, ie never receives a connection string. I'm guessing you've set this up through the designer, if so check the properties of the SQLConnection, and make sure it has a connection string. Another minor issue is that you've specified "fistname" in your click event which I assume should be firstname. If the SQLConnection object does have a connection string, the designer may have messed up, try editing the string slightly through properties and then changing it back.

Hope this helps,

Regards,

Andy
 
You have all sorts of issues there.

1. Your connection has no connection string.
2. Your commands have no connection.
3. You're trying to execute a command and then close the connection without having opened the connection in the first place.
4. Your error handling is all screwed up.
5. You're completely misusing the data adapter.

I suggest that you first of all do a member search for TechGnome and read the ADO.NET tutorial in his signature.
 
connection property has not been initialised

Thanks your response, but the problem still persist.

I have greatly improved on form design and it is very encouraging, however the same error still persist on the form below. I have done the connection string properly the way you suggested. kindly assist. Thank you.


VB.NET:
Imports System.Data.SqlClient
Imports System.Windows.Forms
PublicClass frmTransaction
Inherits System.Windows.Forms.Form
ProtectedConst strConnClass AsString = "workstation id=OGUNDIPE;packet size=4096;integrated security=SSPI;data source=OGUNDIPE;persist security info=False;initial catalog=AR"
Protected strCLASSCMD AsString = "SELECT fclasscd, fclassdes As 'class' FROM tblclass"
Protected dvtblclass As DataView
Protected dstblclass AsNew DataSet
ProtectedConst strConnAgent AsString = "workstation id=OGUNDIPE;packet size=4096;integrated security=SSPI;data source=OGUNDIPE;persist security info=False;initial catalog=AR"
Protected strAGENTCMD AsString = "select fagttransno, fagentdes, fagentcd as 'Agent' from tblAgent"
Protected dvtblAgent As DataView
Protected dstblAgent AsNew DataSet
ProtectedConst strConnBranch AsString = "workstation id=OGUNDIPE;packet size=4096;integrated security=SSPI;data source=OGUNDIPE;persist security info=False;initial catalog=AR"
Protected strBRANCHCMD AsString = "select fcono, coname as 'Branch' from tblBranch"
Protected dvtblBranch As DataView
Protected dstblBranch AsNew DataSet
#Region " Windows Form Designer generated code "
PublicSubNew()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
ARSqlConnection.Open()
Dim reader As SqlDataReader
EndSub
'Form overrides dispose to clean up the component list.
ProtectedOverloadsOverridesSub Dispose(ByVal disposing AsBoolean)
If disposing Then
IfNot (components IsNothing) Then
components.Dispose()
EndIf
EndIf
MyBase.Dispose(disposing)
EndSub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer. 
'Do not modify it using the code editor.
FriendWithEvents lblDataPage1 As System.Windows.Forms.Label
FriendWithEvents lblDataPage2 As System.Windows.Forms.Label
FriendWithEvents lblSno As System.Windows.Forms.Label
FriendWithEvents lblTransType As System.Windows.Forms.Label
FriendWithEvents lblPolicyNo As System.Windows.Forms.Label
FriendWithEvents lblClassCode As System.Windows.Forms.Label
FriendWithEvents lblAccountNo As System.Windows.Forms.Label
FriendWithEvents lblGrossPrem As System.Windows.Forms.Label
FriendWithEvents lblCommDeduc As System.Windows.Forms.Label
FriendWithEvents lblClientName As System.Windows.Forms.Label
FriendWithEvents lblBuzType As System.Windows.Forms.Label
FriendWithEvents lblAddress As System.Windows.Forms.Label
FriendWithEvents lblInsured As System.Windows.Forms.Label
FriendWithEvents lblTransDate As System.Windows.Forms.Label
FriendWithEvents lblParticulars As System.Windows.Forms.Label
FriendWithEvents lblBusLegend As System.Windows.Forms.Label
FriendWithEvents lblAgentCode As System.Windows.Forms.Label
FriendWithEvents txtSNo As System.Windows.Forms.TextBox
FriendWithEvents txtAccountNo As System.Windows.Forms.TextBox
FriendWithEvents txtPolicyNo As System.Windows.Forms.TextBox
FriendWithEvents txtClientName As System.Windows.Forms.TextBox
FriendWithEvents txtGrossPrem As System.Windows.Forms.TextBox
FriendWithEvents txtCommDeduc As System.Windows.Forms.TextBox
FriendWithEvents txtAddress1 As System.Windows.Forms.TextBox
FriendWithEvents txtAddress2 As System.Windows.Forms.TextBox
FriendWithEvents txtInsured As System.Windows.Forms.TextBox
FriendWithEvents txtTransDate As System.Windows.Forms.TextBox
FriendWithEvents cboTransType As System.Windows.Forms.ComboBox
FriendWithEvents cboClassCode As System.Windows.Forms.ComboBox
FriendWithEvents cboAgentCode As System.Windows.Forms.ComboBox
FriendWithEvents AddRec As System.Windows.Forms.Button
FriendWithEvents cmdDeleteRec As System.Windows.Forms.Button
FriendWithEvents FindRec As System.Windows.Forms.Button
FriendWithEvents cmdExitRec As System.Windows.Forms.Button
FriendWithEvents cboBuzType As System.Windows.Forms.ComboBox
FriendWithEvents cboBuzLeg As System.Windows.Forms.ComboBox
FriendWithEvents txtPart1 As System.Windows.Forms.TextBox
FriendWithEvents txtPart2 As System.Windows.Forms.TextBox
FriendWithEvents cboBranchCode As System.Windows.Forms.ComboBox
FriendWithEvents lblBranchCode As System.Windows.Forms.Label
FriendWithEvents cmdModify As System.Windows.Forms.Button
FriendWithEvents ARDataSet As System.Data.DataSet
FriendWithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
FriendWithEvents ARSqlDataAdapter As System.Data.SqlClient.SqlDataAdapter
FriendWithEvents ARSqlCommand As System.Data.SqlClient.SqlCommand
FriendWithEvents ARSqlConnection As System.Data.SqlClient.SqlConnection
<System.Diagnostics.DebuggerStepThrough()> PrivateSub InitializeComponent()
Me.lblDataPage1 = New System.Windows.Forms.Label
Me.lblDataPage2 = New System.Windows.Forms.Label
Me.lblSno = New System.Windows.Forms.Label
Me.lblTransType = New System.Windows.Forms.Label
Me.lblPolicyNo = New System.Windows.Forms.Label
Me.lblClassCode = New System.Windows.Forms.Label
Me.lblAccountNo = New System.Windows.Forms.Label
Me.lblGrossPrem = New System.Windows.Forms.Label
Me.lblCommDeduc = New System.Windows.Forms.Label
Me.lblClientName = New System.Windows.Forms.Label
Me.lblBuzType = New System.Windows.Forms.Label
Me.lblAddress = New System.Windows.Forms.Label
Me.lblInsured = New System.Windows.Forms.Label
Me.lblTransDate = New System.Windows.Forms.Label
Me.lblParticulars = New System.Windows.Forms.Label
Me.lblBusLegend = New System.Windows.Forms.Label
Me.lblAgentCode = New System.Windows.Forms.Label
Me.txtSNo = New System.Windows.Forms.TextBox
Me.txtAccountNo = New System.Windows.Forms.TextBox
Me.txtPolicyNo = New System.Windows.Forms.TextBox
Me.txtClientName = New System.Windows.Forms.TextBox
Me.txtGrossPrem = New System.Windows.Forms.TextBox
Me.txtCommDeduc = New System.Windows.Forms.TextBox
Me.txtAddress1 = New System.Windows.Forms.TextBox
Me.txtAddress2 = New System.Windows.Forms.TextBox
Me.txtInsured = New System.Windows.Forms.TextBox
Me.txtTransDate = New System.Windows.Forms.TextBox
Me.txtPart1 = New System.Windows.Forms.TextBox
Me.txtPart2 = New System.Windows.Forms.TextBox
Me.cboTransType = New System.Windows.Forms.ComboBox
Me.cboClassCode = New System.Windows.Forms.ComboBox
Me.cboBuzType = New System.Windows.Forms.ComboBox
Me.cboBuzLeg = New System.Windows.Forms.ComboBox
Me.cboAgentCode = New System.Windows.Forms.ComboBox
Me.AddRec = New System.Windows.Forms.Button
Me.cmdDeleteRec = New System.Windows.Forms.Button
Me.FindRec = New System.Windows.Forms.Button
Me.cmdExitRec = New System.Windows.Forms.Button
Me.cboBranchCode = New System.Windows.Forms.ComboBox
Me.lblBranchCode = New System.Windows.Forms.Label
Me.cmdModify = New System.Windows.Forms.Button
Me.ARDataSet = New System.Data.DataSet
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand
Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand
Me.ARSqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter
Me.ARSqlCommand = New System.Data.SqlClient.SqlCommand
Me.ARSqlConnection = New System.Data.SqlClient.SqlConnection
CType(Me.ARDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'lblDataPage1
'
Me.lblDataPage1.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblDataPage1.Location = New System.Drawing.Point(128, 8)
Me.lblDataPage1.Name = "lblDataPage1"
Me.lblDataPage1.Size = New System.Drawing.Size(456, 24)
Me.lblDataPage1.TabIndex = 0
Me.lblDataPage1.Text = "DATA ENTRY FILE MAINTENANCE"
'
'lblDataPage2
'
Me.lblDataPage2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblDataPage2.Location = New System.Drawing.Point(128, 40)
Me.lblDataPage2.Name = "lblDataPage2"
Me.lblDataPage2.Size = New System.Drawing.Size(424, 24)
Me.lblDataPage2.TabIndex = 1
Me.lblDataPage2.Text = "DR NOTE, CR NOTE, RECEIPTS AND COMMISSION VOUCHERS"
'
'lblSno
'
Me.lblSno.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblSno.Location = New System.Drawing.Point(0, 72)
Me.lblSno.Name = "lblSno"
Me.lblSno.TabIndex = 2
Me.lblSno.Text = "S/No"
'
'lblTransType
'
Me.lblTransType.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTransType.Location = New System.Drawing.Point(0, 104)
Me.lblTransType.Name = "lblTransType"
Me.lblTransType.TabIndex = 5
Me.lblTransType.Text = "Trans.Type"
'
'lblPolicyNo
'
Me.lblPolicyNo.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblPolicyNo.Location = New System.Drawing.Point(0, 128)
Me.lblPolicyNo.Name = "lblPolicyNo"
Me.lblPolicyNo.TabIndex = 7
Me.lblPolicyNo.Text = "Policy No"
'
'lblClassCode
'
Me.lblClassCode.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblClassCode.Location = New System.Drawing.Point(344, 96)
Me.lblClassCode.Name = "lblClassCode"
Me.lblClassCode.Size = New System.Drawing.Size(120, 16)
Me.lblClassCode.TabIndex = 9
Me.lblClassCode.Text = "Class Code"
'
'lblAccountNo
'
Me.lblAccountNo.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblAccountNo.Location = New System.Drawing.Point(344, 128)
Me.lblAccountNo.Name = "lblAccountNo"
Me.lblAccountNo.Size = New System.Drawing.Size(120, 16)
Me.lblAccountNo.TabIndex = 11
Me.lblAccountNo.Text = "Account No"
'
'lblGrossPrem
'
Me.lblGrossPrem.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblGrossPrem.Location = New System.Drawing.Point(344, 160)
Me.lblGrossPrem.Name = "lblGrossPrem"
Me.lblGrossPrem.Size = New System.Drawing.Size(120, 16)
Me.lblGrossPrem.TabIndex = 13
Me.lblGrossPrem.Text = "Gross Premium"
'
'lblCommDeduc
'
Me.lblCommDeduc.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblCommDeduc.Location = New System.Drawing.Point(344, 192)
Me.lblCommDeduc.Name = "lblCommDeduc"
Me.lblCommDeduc.Size = New System.Drawing.Size(120, 16)
Me.lblCommDeduc.TabIndex = 15
Me.lblCommDeduc.Text = "Comm.Deductible"
'
'lblClientName
'
Me.lblClientName.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblClientName.Location = New System.Drawing.Point(0, 160)
Me.lblClientName.Name = "lblClientName"
Me.lblClientName.TabIndex = 17
Me.lblClientName.Text = "Name of Client"
'
'lblBuzType
'
Me.lblBuzType.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblBuzType.Location = New System.Drawing.Point(0, 192)
Me.lblBuzType.Name = "lblBuzType"
Me.lblBuzType.TabIndex = 19
Me.lblBuzType.Text = "Buz. Type"
'
'lblAddress
'
Me.lblAddress.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblAddress.Location = New System.Drawing.Point(0, 224)
Me.lblAddress.Name = "lblAddress"
Me.lblAddress.TabIndex = 21
Me.lblAddress.Text = "Address"
'
'lblInsured
'
Me.lblInsured.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblInsured.Location = New System.Drawing.Point(0, 280)
Me.lblInsured.Name = "lblInsured"
Me.lblInsured.TabIndex = 23
Me.lblInsured.Text = "Insured"
'
'lblTransDate
'
Me.lblTransDate.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTransDate.Location = New System.Drawing.Point(0, 312)
Me.lblTransDate.Name = "lblTransDate"
Me.lblTransDate.TabIndex = 25
Me.lblTransDate.Text = "Trans.Date"
'
'lblParticulars
'
Me.lblParticulars.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblParticulars.Location = New System.Drawing.Point(0, 344)
Me.lblParticulars.Name = "lblParticulars"
Me.lblParticulars.TabIndex = 27
Me.lblParticulars.Text = "Particulars"
'
'lblBusLegend
'
Me.lblBusLegend.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblBusLegend.Location = New System.Drawing.Point(0, 400)
Me.lblBusLegend.Name = "lblBusLegend"
Me.lblBusLegend.Size = New System.Drawing.Size(112, 23)
Me.lblBusLegend.TabIndex = 29
Me.lblBusLegend.Text = "Business Legend"
'
'lblAgentCode
'
Me.lblAgentCode.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblAgentCode.Location = New System.Drawing.Point(0, 432)
Me.lblAgentCode.Name = "lblAgentCode"
Me.lblAgentCode.TabIndex = 31
Me.lblAgentCode.Text = "Agent Code"
'
'txtSNo
'
Me.txtSNo.Location = New System.Drawing.Point(112, 72)
Me.txtSNo.Name = "txtSNo"
Me.txtSNo.TabIndex = 32
Me.txtSNo.Text = ""
'
'txtAccountNo
'
Me.txtAccountNo.Location = New System.Drawing.Point(480, 128)
Me.txtAccountNo.Name = "txtAccountNo"
Me.txtAccountNo.TabIndex = 33
Me.txtAccountNo.Text = ""
'
'txtPolicyNo
'
Me.txtPolicyNo.Location = New System.Drawing.Point(112, 128)
Me.txtPolicyNo.Name = "txtPolicyNo"
Me.txtPolicyNo.TabIndex = 34
Me.txtPolicyNo.Text = ""
'
'txtClientName
'
Me.txtClientName.Location = New System.Drawing.Point(112, 160)
Me.txtClientName.Name = "txtClientName"
Me.txtClientName.TabIndex = 35
Me.txtClientName.Text = ""
'
'txtGrossPrem
'
Me.txtGrossPrem.Location = New System.Drawing.Point(480, 160)
Me.txtGrossPrem.Name = "txtGrossPrem"
Me.txtGrossPrem.TabIndex = 36
Me.txtGrossPrem.Text = ""
'
'txtCommDeduc
'
Me.txtCommDeduc.Location = New System.Drawing.Point(480, 192)
Me.txtCommDeduc.Name = "txtCommDeduc"
Me.txtCommDeduc.TabIndex = 37
Me.txtCommDeduc.Text = ""
'
'txtAddress1
'
Me.txtAddress1.Location = New System.Drawing.Point(112, 224)
Me.txtAddress1.Name = "txtAddress1"
Me.txtAddress1.Size = New System.Drawing.Size(296, 20)
Me.txtAddress1.TabIndex = 38
Me.txtAddress1.Text = ""
'
'txtAddress2
'
Me.txtAddress2.Location = New System.Drawing.Point(112, 248)
Me.txtAddress2.Name = "txtAddress2"
Me.txtAddress2.Size = New System.Drawing.Size(296, 20)
Me.txtAddress2.TabIndex = 39
Me.txtAddress2.Text = ""
'
'txtInsured
'
Me.txtInsured.Location = New System.Drawing.Point(112, 280)
Me.txtInsured.Name = "txtInsured"
Me.txtInsured.Size = New System.Drawing.Size(248, 20)
Me.txtInsured.TabIndex = 40
Me.txtInsured.Text = ""
'
'txtTransDate
'
Me.txtTransDate.Location = New System.Drawing.Point(112, 312)
Me.txtTransDate.Name = "txtTransDate"
Me.txtTransDate.Size = New System.Drawing.Size(96, 20)
Me.txtTransDate.TabIndex = 41
Me.txtTransDate.Text = ""
'
'txtPart1
'
Me.txtPart1.Location = New System.Drawing.Point(112, 344)
Me.txtPart1.Name = "txtPart1"
Me.txtPart1.Size = New System.Drawing.Size(296, 20)
Me.txtPart1.TabIndex = 42
Me.txtPart1.Text = ""
'
'txtPart2
'
Me.txtPart2.Location = New System.Drawing.Point(112, 368)
Me.txtPart2.Name = "txtPart2"
Me.txtPart2.Size = New System.Drawing.Size(296, 20)
Me.txtPart2.TabIndex = 43
Me.txtPart2.Text = ""
'
'cboTransType
'
Me.cboTransType.Items.AddRange(NewObject() {"DBN", "CRN", "RCP", "PMT"})
Me.cboTransType.Location = New System.Drawing.Point(112, 96)
Me.cboTransType.Name = "cboTransType"
Me.cboTransType.Size = New System.Drawing.Size(160, 21)
Me.cboTransType.TabIndex = 44
'
'cboClassCode
'
Me.cboClassCode.Location = New System.Drawing.Point(480, 96)
Me.cboClassCode.Name = "cboClassCode"
Me.cboClassCode.Size = New System.Drawing.Size(200, 21)
Me.cboClassCode.TabIndex = 45
'
'cboBuzType
'
Me.cboBuzType.Items.AddRange(NewObject() {"DRCT", "ACPT", "CO-IN"})
Me.cboBuzType.Location = New System.Drawing.Point(112, 192)
Me.cboBuzType.Name = "cboBuzType"
Me.cboBuzType.Size = New System.Drawing.Size(160, 21)
Me.cboBuzType.TabIndex = 46
'
'cboBuzLeg
'
Me.cboBuzLeg.Items.AddRange(NewObject() {"EXS", "ADD", "NEW"})
Me.cboBuzLeg.Location = New System.Drawing.Point(112, 400)
Me.cboBuzLeg.Name = "cboBuzLeg"
Me.cboBuzLeg.Size = New System.Drawing.Size(160, 21)
Me.cboBuzLeg.TabIndex = 47
'
'cboAgentCode
'
Me.cboAgentCode.Location = New System.Drawing.Point(112, 432)
Me.cboAgentCode.Name = "cboAgentCode"
Me.cboAgentCode.Size = New System.Drawing.Size(216, 21)
Me.cboAgentCode.TabIndex = 48
'
'AddRec
'
Me.AddRec.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.AddRec.Location = New System.Drawing.Point(40, 472)
Me.AddRec.Name = "AddRec"
Me.AddRec.Size = New System.Drawing.Size(96, 32)
Me.AddRec.TabIndex = 49
Me.AddRec.Text = "Add Record"
'
'cmdDeleteRec
'
Me.cmdDeleteRec.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdDeleteRec.Location = New System.Drawing.Point(416, 472)
Me.cmdDeleteRec.Name = "cmdDeleteRec"
Me.cmdDeleteRec.Size = New System.Drawing.Size(96, 32)
Me.cmdDeleteRec.TabIndex = 50
Me.cmdDeleteRec.Text = "Delete Record"
'
'FindRec
'
Me.FindRec.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.FindRec.Location = New System.Drawing.Point(160, 472)
Me.FindRec.Name = "FindRec"
Me.FindRec.Size = New System.Drawing.Size(96, 32)
Me.FindRec.TabIndex = 51
Me.FindRec.Text = "Find Record"
'
'cmdExitRec
'
Me.cmdExitRec.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdExitRec.Location = New System.Drawing.Point(544, 472)
Me.cmdExitRec.Name = "cmdExitRec"
Me.cmdExitRec.Size = New System.Drawing.Size(96, 32)
Me.cmdExitRec.TabIndex = 52
Me.cmdExitRec.Text = "Exit"
'
'cboBranchCode
'
Me.cboBranchCode.Location = New System.Drawing.Point(448, 432)
Me.cboBranchCode.Name = "cboBranchCode"
Me.cboBranchCode.Size = New System.Drawing.Size(208, 21)
Me.cboBranchCode.TabIndex = 54
'
'lblBranchCode
'
Me.lblBranchCode.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblBranchCode.Location = New System.Drawing.Point(328, 432)
Me.lblBranchCode.Name = "lblBranchCode"
Me.lblBranchCode.Size = New System.Drawing.Size(192, 16)
Me.lblBranchCode.TabIndex = 53
Me.lblBranchCode.Text = "Branch Code"
'
'cmdModify
'
Me.cmdModify.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdModify.Location = New System.Drawing.Point(280, 472)
Me.cmdModify.Name = "cmdModify"
Me.cmdModify.Size = New System.Drawing.Size(112, 32)
Me.cmdModify.TabIndex = 55
Me.cmdModify.Text = "Modify Record"
'
'ARDataSet
'
Me.ARDataSet.DataSetName = "NewDataSet"
Me.ARDataSet.Locale = New System.Globalization.CultureInfo("en-US")
'
'ARSqlDataAdapter
'
Me.ARSqlDataAdapter.DeleteCommand = Me.SqlDeleteCommand1
Me.ARSqlDataAdapter.InsertCommand = Me.SqlInsertCommand1
Me.ARSqlDataAdapter.SelectCommand = Me.SqlSelectCommand1
Me.ARSqlDataAdapter.UpdateCommand = Me.SqlUpdateCommand1
'
'ARSqlConnection
'
Me.ARSqlConnection.ConnectionString = "workstation id=OGUNDIPE;packet size=4096;integrated security=SSPI;data source=OGU" & _
"NDIPE;persist security info=False;initial catalog=AR"
'
'frmTransaction
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(688, 510)
Me.Controls.Add(Me.cmdModify)
Me.Controls.Add(Me.cboBranchCode)
Me.Controls.Add(Me.lblBranchCode)
Me.Controls.Add(Me.cmdExitRec)
Me.Controls.Add(Me.FindRec)
Me.Controls.Add(Me.cmdDeleteRec)
Me.Controls.Add(Me.AddRec)
Me.Controls.Add(Me.cboAgentCode)
Me.Controls.Add(Me.cboBuzLeg)
Me.Controls.Add(Me.cboBuzType)
Me.Controls.Add(Me.cboClassCode)
Me.Controls.Add(Me.cboTransType)
Me.Controls.Add(Me.txtPart2)
Me.Controls.Add(Me.txtPart1)
Me.Controls.Add(Me.txtTransDate)
Me.Controls.Add(Me.txtInsured)
Me.Controls.Add(Me.txtAddress2)
Me.Controls.Add(Me.txtAddress1)
Me.Controls.Add(Me.txtCommDeduc)
Me.Controls.Add(Me.txtGrossPrem)
Me.Controls.Add(Me.txtClientName)
Me.Controls.Add(Me.txtPolicyNo)
Me.Controls.Add(Me.txtAccountNo)
Me.Controls.Add(Me.txtSNo)
Me.Controls.Add(Me.lblAgentCode)
Me.Controls.Add(Me.lblBusLegend)
Me.Controls.Add(Me.lblParticulars)
Me.Controls.Add(Me.lblTransDate)
Me.Controls.Add(Me.lblInsured)
Me.Controls.Add(Me.lblAddress)
Me.Controls.Add(Me.lblBuzType)
Me.Controls.Add(Me.lblClientName)
Me.Controls.Add(Me.lblCommDeduc)
Me.Controls.Add(Me.lblGrossPrem)
Me.Controls.Add(Me.lblAccountNo)
Me.Controls.Add(Me.lblClassCode)
Me.Controls.Add(Me.lblPolicyNo)
Me.Controls.Add(Me.lblTransType)
Me.Controls.Add(Me.lblSno)
Me.Controls.Add(Me.lblDataPage2)
Me.Controls.Add(Me.lblDataPage1)
Me.Name = "frmTransaction"
Me.Text = "Form1"
CType(Me.ARDataSet, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
EndSub
#EndRegion
' Add Record
PrivateSub AddRec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddRec.Click
'Try
'Return current system date
Dim txtdate AsDate
txtdate = Today
' txtdate = Date.Now.ToString
'The following codes is just to guide me in future in respect of date 
'This(moment = Now) 'assign current sytem date and time
'MessageBox.Show("The current system is " & DaARring)
Dim strMessage AsString
'ensure first and last name input
If Trim(txtSNo.Text <> "" AndAlso txtClientName.Text <> "" AndAlso txtPolicyNo.Text <> "") Then
'To check date validity
If txtTransDate.Text < #1/1/1992# Then
MessageBox.Show("Please enter the correct date", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIfNot IsNumeric(txtGrossPrem.Text) Then
strMessage = "Please enter numeric values in Gross premium fields"
MessageBox.Show(strMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ElseIfNot IsNumeric(txtCommDeduc.Text) Then
MessageBox.Show("Please enter numeric values in Commission fields", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
Dim dReader As System.Data.SqlClient.SqlDataReader
ARSqlDataAdapter.SelectCommand.CommandText = "SELECT * FROM tbldebitold WHERE fserialno = '" & txtSNo.Text & "'"
'ARSqlConnection.Open()
dReader = ARSqlCommand.ExecuteReader
If dReader.HasRows Then
MessageBox.Show("Record already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ARSqlConnection.Close()
'create first the SQL query to insert a row
ARSqlDataAdapter.InsertCommand.CommandText = _
"INSERT INTO tbldebitold(fserialno, ftrans, fpolno, fname, faccdir, faddr1, faddr2, finsured, fmending, fpart1, fpart2, fbusleg, fagentcd, fcono, fclasscd, faccno, fgrssprm, fentrydt, fcomm)" & _
"VALUES('" & txtSNo.Text & "','" & cboTransType.Text & "','" & txtPolicyNo.Text & "','" & txtClientName.Text & "','" & cboBuzType.Text & "','" & txtAddress1.Text & "','" & txtAddress2.Text & "' " & _
"'" & txtTransDate.Text & "','" & txtPart1.Text & "','" & txtPart2.Text & "','" & cboBuzLeg.Text & "','" & cboAgentCode.Text & "','" & cboBranchCode.Text & "','" & cboClassCode.Text & "'," & _
"'" & txtAccountNo.Text & "','" & txtGrossPrem.Text & "','" & txtdate & "','" & txtCommDeduc.Text & "',"
'send Data
ARSqlDataAdapter.InsertCommand.ExecuteNonQuery()
MessageBox.Show("Adding Successful", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
ARSqlConnection.Close()
txtSNo.Clear()
ClearTextBoxes()
EndIf
EndIf
MessageBox.Show("Information Ok", MessageBoxIcon.Information, MessageBoxButtons.OK)
' End Try
'Else
EndIf
EndSub
' Exit Application
PrivateSub cmdExitRec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExitRec.Click
Application.Exit()
EndSub'Exit click
'finds record in database
PrivateSub FindRec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FindRec.Click
Try
'ensure user input last name 
If Trim(txtSNo.Text) <> "" Then
'clear DataSet from last operation
ARDataSet.Clear()
'create SQL query to find contact with specified serial no
ARSqlDataAdapter.SelectCommand.CommandText = _
"SELECT * FROM tbldebitold WHERE fserialno = '" & txtSNo.Text & "'"
'fill ARDataSet with the rows resulting from the query
ARSqlDataAdapter.Fill(ARDataSet)
'displayInformation
Display(ARDataSet)
'MessageBox.Show("Query successful")
'prompt user for last name
Else
'Display popup box
MessageBox.Show("Please enter SErial No.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
'txtMessage.Text = "Enter SErial No. then press Find"
EndIf
' display vertbose information with database exception
Catch SQLExceptionParameter As System.Data.Sqlclient.SqlException
'Console.WriteLine(SQLExceptionParameter.StackTrace)
'txtMessage.Text &= SQLExceptionParameter.ToString)
'display message box when invalid operation
Catch ex As Exception
MessageBox.Show("Invalid Operation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
EndTry
EndSub
 
'displays data in dataset
PrivateSub Display(ByVal dataset As DataSet)
Try
'get first DataTable - there will be one
Dim dataTable As DataTable = dataset.Tables(0)
'ensure dataTable not empty
If dataTable.Rows.Count <> 0 Then
Dim recordNumber AsInteger = _
Convert.ToInt32(dataTable.Rows(0)(0))
txtSNo.Text = recordNumber.ToString
cboTransType.Text = Convert.ToString(dataTable.Rows(0)(1))
txtPolicyNo.Text = Convert.ToString(dataTable.Rows(0)(2))
txtClientName.Text = Convert.ToString(dataTable.Rows(0)(3))
cboBuzType.Text = Convert.ToString(dataTable.Rows(0)(4))
txtAddress1.Text = Convert.ToString(dataTable.Rows(0)(5))
txtAddress2.Text = Convert.ToString(dataTable.Rows(0)(6))
txtInsured.Text = Convert.ToString(dataTable.Rows(0)(7))
txtTransDate.Text = Convert.ToString(dataTable.Rows(0)(8))
txtPart1.Text = Convert.ToString(dataTable.Rows(0)(9))
txtPart2.Text = Convert.ToString(dataTable.Rows(0)(10))
cboBuzLeg.Text = Convert.ToString(dataTable.Rows(0)(11))
cboAgentCode.Text = Convert.ToString(dataTable.Rows(0)(12))
' cboBranchCode.Text = Convert.ToString(dataTable.Rows(0)(13))
cboClassCode.Text = Convert.ToString(dataTable.Rows(0)(14))
txtAccountNo.Text = Convert.ToString(dataTable.Rows(0)(15))
cboTransType.Text = Convert.ToString(dataTable.Rows(0)(16))
txtGrossPrem.Text = Convert.ToString(dataTable.Rows(0)(17))
txtCommDeduc.Text = Convert.ToString(dataTable.Rows(0)(18))
EndIf
Catch ex As Exception
EndTry
EndSub' Display
'clears text boxes
PrivateSub ClearTextBoxes()
txtSNo.Clear()
cboTransType.SelectedIndex = 4
txtPolicyNo.Clear()
txtClientName.Clear()
cboBuzType.SelectedIndex = 3
cboBuzLeg.SelectedIndex = 3
txtAddress1.Clear()
txtAddress2.Clear()
txtTransDate.Text = ""
txtPart1.Clear()
txtPart2.Clear()
cboAgentCode.SelectedIndex = 50
cboBranchCode.SelectedIndex = 21
cboClassCode.SelectedIndex = 39
txtAccountNo.Clear()
txtGrossPrem.Clear()
txtCommDeduc.Clear()
EndSub' ClearTextBoxes
'delete record
PrivateSub cmdDeleteRec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDeleteRec.Click
'Try
'make sure user has already found record to Delete
If txtSNo.Text <> "" Then
'set SQL query to Delete all fields in table where id number matches id in idTextBox
ARSqlConnection.Open()
ARSqlDataAdapter.DeleteCommand.CommandText = _
"DELETE FROM tbldebitold WHERE(fserialno = '" & txtSNo.Text & "')"
'execute query
ARSqlDataAdapter.DeleteCommand.ExecuteNonQuery()
MessageBox.Show("Delete Successful")
txtSNo.Clear()
ClearTextBoxes()
Else
'prompt user to input existing record
MessageBox.Show("You can only Delete an existing record. Use Find to locate the record then Delete the Information", MessageBoxIcon.Error, MessageBoxButtons.OK)
ARSqlConnection.Close()
EndIf
MessageBox.Show("Delete Successful", MessageBoxIcon.Information, MessageBoxButtons.OK)
' End Try
EndSub' CmdDelete_Click
'updates etry in database
PrivateSub cmdModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdModify.Click
Try
'make sure user has already found record to update
If txtSNo.Text <> "" Then
'set SQL query to modify all fields in table where id number matches id in idTextBox
ARSqlDataAdapter.UpdateCommand.CommandText = _
"UPDATE tbldebitold SET ftrans='" & cboTransType.Text & "', " & _
"fpolno= '" & txtPolicyNo.Text & "', " & _
"fname= '" & txtClientName.Text & "', " & _
"faccdir= '" & cboBuzType.Text & "', " & _
"faddr1= '" & txtAddress1.Text & "', " & _
"faddr2= '" & txtAddress2.Text & "', " & _
"finsured= '" & txtInsured.Text & "', " & _
"fmending= '" & txtTransDate.Text & "', " & _
"fpart1= '" & txtPart1.Text & "', " & _
"fpart2= '" & txtPart2.Text & "', " & _
"fbusleg= '" & cboBuzLeg.Text & "', " & _
"fagentcd= '" & cboAgentCode.Text & "', " & _
"ffaccno= '" & txtAccountNo.Text & "', " & _
"ffcono= '" & cboBranchCode.Text & "', " & _
"fclasscd= '" & cboClassCode.Text & "', " & _
"fgrssprm= '" & txtGrossPrem.Text & "', " & _
"fcomm= '" & txtCommDeduc.Text & "', "
'notify user that query is being sent
ARSqlConnection.Open()
'execute query
ARSqlDataAdapter.UpdateCommand.ExecuteNonQuery()
MessageBox.Show("Update Successful", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
'prompt user to input existing record
MessageBox.Show("You can only update an existing reoord", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ARSqlConnection.Close()
txtSNo.Clear()
ClearTextBoxes()
EndIf
'display verbose information when database exception
Catch ex As Exception
EndTry
EndSub'cmd Modify_Click
PrivateSub cboClassCode_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
LoadClass()
EndSub
Sub LoadClass()
Try
'Create connection objects
Dim cnClass As SqlConnection = New SqlConnection(strConnClass)
Dim ClassDA AsNew SqlDataAdapter(strCLASSCMD, cnClass)
ClassDA.Fill(dstblclass, "tblclass")
dvtblclass = New DataView(dstblclass.Tables("tblclass"), "", "fclasscd", DataViewRowState.OriginalRows)
With cboClassCode
.ValueMember = "fclasscd"
.DisplayMember = "class"
.DataSource = dvtblclass
EndWith
cboClassCode.SelectedIndex = -1
cnClass.Dispose()
ClassDA.Dispose()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, Me.Text)
'Catch invalidOperationExceptionParameter As InvalidOperationException
' MessageBox.Show(invalidOperationExceptionParameter.Message)
EndTry
EndSub' Load Class
PrivateSub cboAgentCode_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
LoadAgent()
EndSub
Sub LoadAgent()
Try
'Create connection objects
Dim cnAgent As SqlConnection = New SqlConnection(strConnAgent)
Dim AgentDA AsNew SqlDataAdapter(strAGENTCMD, cnAgent)
AgentDA.Fill(dstblAgent, "tblAgent")
dvtblAgent = New DataView(dstblAgent.Tables("tblAgent"), "", "fagttransno", DataViewRowState.OriginalRows)
With cboAgentCode
.ValueMember = "fagttransno"
.DisplayMember = "fagentdes"
.DataSource = dvtblAgent
EndWith
cboBranchCode.SelectedIndex = -1
cnAgent.Dispose()
AgentDA.Dispose()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, Me.Text)
Catch invalidOperationExceptionParameter As InvalidOperationException
'MessageBox.Show(invalidOperationExceptionParameter.Message)
EndTry
EndSub' Load Agentcode
 
PrivateSub cboBranchCode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
LoadBranch()
EndSub
Sub LoadBranch()
Try
'Create connection objects
Dim cnBranch As SqlConnection = New SqlConnection(strConnBranch)
Dim BranchDA AsNew SqlDataAdapter(strBRANCHCMD, cnBranch)
BranchDA.Fill(dstblBranch, "tblBranch")
dvtblBranch = New DataView(dstblBranch.Tables("tblBranch"), "", "fcono", DataViewRowState.OriginalRows)
With cboBranchCode
.ValueMember = "fcono"
.DisplayMember = "Branch"
.DataSource = dvtblBranch
EndWith
cboBranchCode.SelectedIndex = -1
cnBranch.Dispose()
BranchDA.Dispose()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Information, Me.Text)
Catch invalidOperationExceptionParameter As InvalidOperationException
'MessageBox.Show(invalidOperationExceptionParameter.Message)
EndTry
EndSub' Load Branchcode
EndClass'frmTransaction
 
Last edited by a moderator:
That's way too much code. I very much doubt that anyone is going to read anywhere near all of that. You're going to have to condense it to just the relevant parts to have a reasonable chance of getting help. Plus your code has lost all indenting because you didn't post it properly in the first place, making it more difficult to read. The easier you make it for us to help you the more likely it is that you'll get help.
 
Back
Top