"No value given for one or more required parameters."

matt09524

Well-known member
Joined
Sep 14, 2005
Messages
47
This code:

Code:
Imports System.Data.OleDb
Public Class Form2
    Global vars 
    Private dbData(100, 3) As String 
    Private dbPosition1 As Integer = 0

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Debug.WriteLine(Application.StartupPath)
        Try
            Dim dbConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\leadup1.mdb")
            Const sql As String = "SELECT TB_years, TB_names, TB_battles, TB_essays FROM leadup"
            Dim dbCmd As New OleDbCommand(sql, dbConnection)
            Dim results As OleDbDataReader
            Dim i As Integer = 0

            dbConnection.Open()
            results = dbCmd.ExecuteReader()
            Do While results.Read()
                dbData(i, 0) = results.GetString(0)
                dbData(i, 1) = results.GetString(1)
                dbData(i, 2) = results.GetString(2)
                dbData(i, 3) = results.GetString(3)
                i += 1
            Loop
            dbConnection.Close()

        Catch ex As OleDbException
            MessageBox.Show(ex.Message, "Database Error")
        End Try

        If dbPosition1 <= dbData.GetUpperBound(0) Then 
            txtYears.Text = dbData(dbPosition1, 0)
            linkNames1.Text = dbData(dbPosition1, 1)
            txtBattles.Text = dbData(dbPosition1, 2)
            richtxtEssay.Text = dbData(dbPosition1, 3)
            dbPosition1 += 1
        End If

    End Sub

    Private Sub CloseWindow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseWindow.Click
        Me.Close()
    End Sub

End Class

Gives me the subject error and proceeds to load empty data onto form2. I have weeded through errors with this form and this one is killin me. I recreated the database with the exact column names listed in the SQL statement in the code and the path/filename are correct. I have set the colums to allow nulls and zero length data. What am I doing wrong?
 
No. The ide is not catching this. The catch...Try statement is putting up a msgbox while running. I wish it would dime out a line for me so I know where to start :P
 
I fixed this problem. Im not happy about how I fixed it, but it works. I removed the Try...Catch statements and it form loads with the correct data. Now I will just have to reformat the try-catch or use another form of error trapping.
 
Back
Top