Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySQL Database Issue
#1
Hey everybody. I created a shelled version of brandonio's mysql database. I am only using form 3 and form 3 code.
When I run the program I get an error with a null. The data from the database does not come up in the list.

[code2=vbnet]txt_order.Text = splitread(1).ToString[/code2]
^
Object reference not set to an instance of an object.

If anyone has any help on this it would be greatly appreciated.
#2
Hm, in order to fully analyze the issue, we're going to need to see the code that creates the splitread variable and fills it.
My Blog | My Setup | My Videos | Have a wonderful day.
#3
Its a large database, will have lots of data want me to post the entire forms code?
#4
Sure, why not?!
My Blog | My Setup | My Videos | Have a wonderful day.
#5
Alright this is the entire form. I removed some of the login information on purpose btw.

[code2=vbnet]Imports MySql.Data.MySqlClient

Public Class Form1
Public conn As MySqlConnection
Public listbox3 As New ListBox
Public splitread() As String

Private Sub Form1_Load(ByVal sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Dim conn As MySqlConnection
conn = New MySqlConnection("server = ; Port = 3306; user id = root; password = ; Database = dbtest2")
Dim command As New MySqlCommand
Dim sqlquery As String = "SELECT * FROM 'all flood certs'"
Dim adapter As New MySqlDataAdapter
Dim data As MySqlDataReader
conn.Open()
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader
While data.Read()
ListBox1.Items.Add(data(3).ToString)
listbox3.Items.Add(data(0).ToString)
Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/" + data(3).ToString + data(0).ToString + ".txt", False)
writer.Write(data(0).ToString + "=" + data(1).ToString + "=" + data(2).ToString + "=" + data(3).ToString + "=" + data(4).ToString + "=" + data(5).ToString + "=" + data(6).ToString + "=" + data(7).ToString + "=" + data(8).ToString + "=" + data(9).ToString + "=" + data(10).ToString + "=" + data(11).ToString + "=" + data(12).ToString + "=" + data(13).ToString + "=" + data(14).ToString + "=" + data(15).ToString + "=" + data(16).ToString + "=" + data(17).ToString + "=" + data(18).ToString + "=" + data(19).ToString + "=" + data(20).ToString + "=" + data(21).ToString + "=" + data(22).ToString + "=" + data(23).ToString + "=" + data(24).ToString + "=" + data(25).ToString + "=" + data(26).ToString + "=" + data(27).ToString + "=" + data(28).ToString + "=" + data(29).ToString + "=" + data(30).ToString + "=" + data(31).ToString + "=" + data(32).ToString + "=" + data(33).ToString + "=" + data(34).ToString + "=" + data(35).ToString + "=" + data(36).ToString + "=" + data(37).ToString + "=" + data(38).ToString)
writer.Close()
End While
data.Close()
conn.Close()
End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
listbox3.SelectedIndex = ListBox1.SelectedIndex
Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + ListBox1.SelectedItem.ToString + listbox3.SelectedItem.ToString + ".txt")
splitread = reader.ReadToEnd.Split("=")
reader.Close()
lbl_gce.Text = "GCE File : " + splitread(3).ToString
lbl_customer.Text = ("Customer File Number : " + splitread(2).ToString)
lbl_order.Text = ("Order Received : " + splitread(1).ToString)
lbl_borrower.Text = ("Borrower : " + splitread(4).ToString)
lbl_seller.Text = ("Seller : " + splitread(5).ToString)
lbl_street.Text = ("Street Address : " + splitread(6).ToString)
lbl_town.Text = ("Town : " + splitread(7).ToString)
lbl_community.Text = ("Community : " + splitread(8).ToString)
lbl_county.Text = ("County : " + splitread(9).ToString)
lbl_state.Text = ("State : " + splitread(10).ToString)
lbl_zip.Text = ("Zip Code : " + splitread(11).ToString)
lbl_lender.Text = ("Lender : " + splitread(12).ToString)
lbl_attn.Text = ("Attn : " + splitread(13).ToString)
lbl_company.Text = ("Company Name : " + splitread(14).ToString)
lbl_canceled.Text = ("Date Canceled : " + splitread(15).ToString)
lbl_retired.Text = ("Loan Retired : " + splitread(16).ToString)
lbl_loantransfer.Text = ("Loan Transfered : " + splitread(17).ToString)
lbl_transferTo.Text = ("Transfered To : " + splitread(18).ToString)
lbl_transfer.Text = ("Transferbank ID : " + splitread(19).ToString)
lbl_rush.Text = ("Rush : " + splitread(20).ToString)
lbl_invoiced.Text = ("Date Invoiced : " + splitread(21).ToString)
lbl_received.Text = ("Payment Received : " + splitread(22).ToString)
lbl_amountinv.Text = ("Amount Invoiced : " + splitread(23).ToString)
lbl_amountrec.Text = ("Amount Received : " + splitread(24).ToString)
lbl_name.Text = ("Name : " + splitread(25).ToString)
lbl_flood.Text = ("Flood Zone : " + splitread(26).ToString)
lbl_communitynum.Text = ("Community Number : " + splitread(27).ToString)
lbl_panel.Text = ("Panel Number : " + splitread(28).ToString)
lbl_pnp.Text = ("PNP : " + splitread(29).ToString)
lbl_paneldate.Text = ("Panel Date : " + splitread(30).ToString)
lbl_loanmature.Text = ("Loan Maturity Date : " + splitread(31).ToString)
lbl_tax.Text = ("Tax Map Lot : " + splitread(32).ToString)
lbl_ct.Text = ("CT Number : " + splitread(33).ToString)
lbl_msa.Text = ("MSA : " + splitread(34).ToString)
lbl_loma.Text = ("LOMA : " + splitread(35).ToString)
lbl_lomano.Text = ("LOMA NO : " + splitread(36).ToString)
lbl_comments.Text = ("Comments : " + splitread(37).ToString)
lbl_notes.Text = ("Notes : " + splitread(38).ToString)
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked = True Then
'Edit mode is enabled
txt_borrower.Visible = True
txt_seller.Visible = True
txt_gce.Visible = True
txt_customer.Visible = True
txt_order.Visible = True
txt_street.Visible = True
txt_town.Visible = True
txt_community.Visible = True
txt_county.Visible = True
txt_state.Visible = True
txt_zip.Visible = True
txt_lender.Visible = True
txt_attn.Visible = True
txt_company.Visible = True
txt_canceled.Visible = True
txt_retired.Visible = True
txt_loantransfer.Visible = True
txt_transferTo.Visible = True
txt_transfer.Visible = True
txt_rush.Visible = True
txt_invoiced.Visible = True
txt_received.Visible = True
txt_amountinv.Visible = True
txt_amountrec.Visible = True
txt_name.Visible = True
txt_flood.Visible = True
txt_communitynum.Visible = True
txt_panel.Visible = True
txt_pnp.Visible = True
txt_paneldate.Visible = True
txt_loanmature.Visible = True
txt_tax.Visible = True
txt_ct.Visible = True
txt_msa.Visible = True
txt_loma.Visible = True
txt_lomano.Visible = True
txt_comments.Visible = True
txt_notes.Visible = True
txt_order.Text = splitread(1).ToString
txt_customer.Text = splitread(2).ToString
txt_gce.Text = splitread(3).ToString
txt_borrower.Text = splitread(4).ToString
txt_seller.Text = splitread(5).ToString
txt_street.Text = splitread(6).ToString
txt_town.Text = splitread(7).ToString
txt_community.Text = splitread(8).ToString
txt_county.Text = splitread(9).ToString
txt_state.Text = splitread(10).ToString
txt_zip.Text = splitread(11).ToString
txt_lender.Text = splitread(12).ToString
txt_attn.Text = splitread(13).ToString
txt_company.Text = splitread(14).ToString
txt_canceled.Text = splitread(15).ToString
txt_retired.Text = splitread(16).ToString
txt_loantransfer.Text = splitread(17).ToString
txt_transferTo.Text = splitread(18).ToString
txt_transfer.Text = splitread(19).ToString
txt_rush.Text = splitread(20).ToString
txt_invoiced.Text = splitread(21).ToString
txt_received.Text = splitread(22).ToString
txt_amountinv.Text = splitread(23).ToString
txt_amountrec.Text = splitread(24).ToString
txt_name.Text = splitread(25).ToString
txt_flood.Text = splitread(26).ToString
txt_communitynum.Text = splitread(27).ToString
txt_panel.Text = splitread(28).ToString
txt_pnp.Text = splitread(29).ToString
txt_paneldate.Text = splitread(30).ToString
txt_loanmature.Text = splitread(31).ToString
txt_tax.Text = splitread(32).ToString
txt_ct.Text = splitread(33).ToString
txt_msa.Text = splitread(34).ToString
txt_loma.Text = splitread(35).ToString
txt_lomano.Text = splitread(36).ToString
txt_comments.Text = splitread(37).ToString
txt_notes.Text = splitread(38).ToString
lbl_gce.Text = "GCE File : "
lbl_customer.Text = "Customer File Number : "
lbl_order.Text = "Order Received : "
lbl_borrower.Text = "Borrower : "
lbl_seller.Text = "Seller : "
lbl_street.Text = "Street Address : "
lbl_town.Text = "Town : "
lbl_community.Text = "Community : "
lbl_county.Text = "County : "
lbl_state.Text = "State : "
lbl_zip.Text = "Zip Code : "
lbl_lender.Text = "Lender : "
lbl_attn.Text = "Attn : "
lbl_company.Text = "Company Name : "
lbl_canceled.Text = "Date Canceled : "
lbl_retired.Text = "Loan Retired : "
lbl_loantransfer.Text = "Loan Transfered : "
lbl_transferTo.Text = "Transfered To : "
lbl_transfer.Text = "Transferbank ID : "
lbl_rush.Text = "Rush : "
lbl_invoiced.Text = "Date Invoiced : "
lbl_received.Text = "Payment Received : "
lbl_amountinv.Text = "Amount Invoiced : "
lbl_amountrec.Text = "Amount Received : "
lbl_name.Text = "Name : "
lbl_flood.Text = "Flood Zone : "
lbl_communitynum.Text = "Community Number : "
lbl_panel.Text = "Panel Number : "
lbl_pnp.Text = "PNP : "
lbl_paneldate.Text = "Panel Date : "
lbl_loanmature.Text = "Loan Maturity Date : "
lbl_tax.Text = "Tax Map Lot : "
lbl_ct.Text = "CT Number : "
lbl_msa.Text = "MSA : "
lbl_loma.Text = "LOMA : "
lbl_lomano.Text = "LOMA NO : "
lbl_comments.Text = "Comments : "
lbl_notes.Text = "Notes : "
Button1.Visible = True

Else
'Edit mode is disabled
txt_borrower.Visible = False
txt_seller.Visible = False
txt_gce.Visible = False
txt_customer.Visible = False
txt_order.Visible = False
txt_street.Visible = False
txt_town.Visible = False
txt_community.Visible = False
txt_county.Visible = False
txt_state.Visible = False
txt_zip.Visible = False
txt_lender.Visible = False
txt_attn.Visible = False
txt_company.Visible = False
txt_canceled.Visible = False
txt_retired.Visible = False
txt_loantransfer.Visible = False
txt_transferTo.Visible = False
txt_transfer.Visible = False
txt_rush.Visible = False
txt_invoiced.Visible = False
txt_received.Visible = False
txt_amountinv.Visible = False
txt_amountrec.Visible = False
txt_name.Visible = False
txt_flood.Visible = False
txt_communitynum.Visible = False
txt_panel.Visible = False
txt_pnp.Visible = False
txt_paneldate.Visible = False
txt_loanmature.Visible = False
txt_tax.Visible = False
txt_ct.Visible = False
txt_msa.Visible = False
txt_loma.Visible = False
txt_lomano.Visible = False
txt_comments.Visible = False
txt_notes.Visible = False
lbl_gce.Text = "GCE File : "
lbl_customer.Text = "Customer File Number : "
lbl_order.Text = "Order Received : "
lbl_borrower.Text = "Borrower : "
lbl_seller.Text = "Seller : "
lbl_street.Text = "Street Address : "
lbl_town.Text = "Town : "
lbl_community.Text = "Community : "
lbl_county.Text = "County : "
lbl_state.Text = "State : "
lbl_zip.Text = "Zip Code : "
lbl_lender.Text = "Lender : "
lbl_attn.Text = "Attn : "
lbl_company.Text = "Company Name : "
lbl_canceled.Text = "Date Canceled : "
lbl_retired.Text = "Loan Retired : "
lbl_loantransfer.Text = "Loan Transfered : "
lbl_transferTo.Text = "Transfered To : "
lbl_transfer.Text = "Transferbank ID : "
lbl_rush.Text = "Rush : "
lbl_invoiced.Text = "Date Invoiced : "
lbl_received.Text = "Payment Received : "
lbl_amountinv.Text = "Amount Invoiced : "
lbl_amountrec.Text = "Amount Received : "
lbl_name.Text = "Name : "
lbl_flood.Text = "Flood Zone : "
lbl_communitynum.Text = "Community Number : "
lbl_panel.Text = "Panel Number : "
lbl_pnp.Text = "PNP : "
lbl_paneldate.Text = "Panel Date : "
lbl_loanmature.Text = "Loan Maturity Date : "
lbl_tax.Text = "Tax Map Lot : "
lbl_ct.Text = "CT Number : "
lbl_msa.Text = "MSA : "
lbl_loma.Text = "LOMA : "
lbl_lomano.Text = "LOMA NO : "
lbl_comments.Text = "Comments : "
lbl_notes.Text = "Notes : "
Button1.Visible = False
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim conn As MySqlConnection
conn = New MySqlConnection("server = ; Port = 3306; user id = root; password = ; database = dbtest2")
Dim command As New MySqlCommand
Dim sqlquery As String = "UPDATE 'all flood certs' SET Order Received='" & txt_order.Text & "', Customer File Number='" & txt_customer.Text & "', GCE File='" & txt_gce.Text & "', Borrower='" & txt_borrower.Text & "', Seller='" & txt_seller.Text & "', Street Address='" & txt_street.Text & "', Town='" & txt_town.Text & "', Community='" & txt_community.Text & "', County='" & txt_county.Text & "', State='" & txt_state.Text & "', Zip Code='" & txt_zip.Text & "', Lender='" & txt_lender.Text & "', Attn='" & txt_attn.Text & "', Company Name='" & txt_company.Text & "', Date Canceled='" & txt_canceled.Text & "', Loan Retired='" & txt_retired.Text & "', Loan Transfered='" & txt_loantransfer.Text & "', Transfered To='" & txt_transferTo.Text & "', Transferbank ID='" & txt_transfer.Text & "', Rush='" & txt_rush.Text & "', Date Invoiced='" & txt_invoiced.Text & "', Payment Received='" & txt_received.Text & "', Amount Invoiced='" & txt_amountinv.Text & "', Amount Received='" & txt_amountrec.Text & "', Name='" & txt_name.Text & "', Flood Zone='" & txt_flood.Text & "', Community Number='" & txt_communitynum.Text & "', Panel Number='" & txt_panel.Text & "', PNP='" & txt_pnp.Text & "', Panel Date='" & txt_paneldate.Text & "', Loan Maturity Date='" & txt_loanmature.Text & "', Tax Map Lot='" & txt_tax.Text & "', CT Number='" & txt_ct.Text & "', MSA='" & txt_msa.Text & "', LOMA='" & txt_loma.Text & "', LOMA NO='" & txt_lomano.Text & "', Comment='" & txt_comments.Text & "', Notes='" & txt_notes.Text & "WHERE ID='" & listbox3.SelectedItem & "';"
Dim adapter As New MySqlDataAdapter
Dim data As MySqlDataReader
conn.Open()
command.CommandText = sqlquery
command.Connection = conn
adapter.SelectCommand = command
data = command.ExecuteReader

data.Close()
conn.Close()

Me.Close()
Me.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, e As System.EventArgs) Handles Button2.Click
Dim conn As MySqlConnection
conn = New MySqlConnection("server = ; Port = 3306; user id = root; password = ; Database = dbtest2")
Dim command As New MySqlCommand
Dim sqlquery As String = "DELETE From 'all flood certs' WHERE ID='" & listbox3.SelectedItem.ToString & "';"
Dim Adapter As New MySqlDataAdapter
Dim data As MySqlDataReader
conn.Open()
command.Connection = conn
command.CommandText = sqlquery
Adapter.SelectCommand = command
data = command.ExecuteReader

data.Close()
data.Close()
Me.Close()
Dim Form1 As New Form1
Form1.Show()

End Sub
End Class[/code2]
#6
Well, since the error occurs when you try to fill a textbox with a variable, I would say that there would be a problem when you filled the variable. However.

[code2=vbnet]splitread = reader.ReadToEnd.Split("=")[/code2]
Seems to be perfectly fine...

Instead of using an array of strings, try having a List(Of String), that may fix it.. But I have no clue at this point.
My Blog | My Setup | My Videos | Have a wonderful day.
#7
A list of strings?
#8
Yeah, but I am not positive that will solve the problem. I have a video discussing Lists here:

<!-- m --><a class="postlink" href="http://www.youtube.com/watch?v=oJo4gbySk1Q&feature=plcp">http://www.youtube.com/watch?v=oJo4gbySk1Q&feature=plcp</a><!-- m -->
My Blog | My Setup | My Videos | Have a wonderful day.


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I read a link from mysql databse??? mnxford 9 33,066 04-12-2013, 06:27 PM
Last Post: brandonio21
  Relationship Database help. Worf 0 7,736 03-06-2013, 09:05 AM
Last Post: Worf
  How do I use Listview to delete MySQL DB records kismetgerald 10 33,895 11-28-2012, 05:19 PM
Last Post: brandonio21
  [SOLVED] MySQL Update Query - What am I doing wrong? kismetgerald 11 43,372 10-18-2012, 07:16 PM
Last Post: brandonio21
  How do I fill my form with MySQL data based on Combobox? kismetgerald 8 26,741 10-14-2012, 09:05 PM
Last Post: brandonio21
  Help with creating an INSERT statement using MySQL kismetgerald 4 16,777 08-30-2012, 03:03 PM
Last Post: brandonio21
  Dual Menu Strip Issue Moldraxian 3 16,862 08-15-2012, 12:36 PM
Last Post: brandonio21
  MySql Database Queries in VB.Net Moldraxian 6 22,406 07-26-2012, 03:44 PM
Last Post: Moldraxian
  Module Issue Vinwarez 18 59,449 07-24-2012, 11:47 PM
Last Post: Vinwarez
  How to Package MySql Connector and MySql Program? Moldraxian 3 14,777 07-20-2012, 12:23 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)