matt09524 Posted September 27, 2005 Posted September 27, 2005 This 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? Quote
fizzled Posted September 27, 2005 Posted September 27, 2005 Does it tell you what line is causing the error? Quote
matt09524 Posted September 27, 2005 Author Posted September 27, 2005 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 Quote
Administrators PlausiblyDamp Posted September 27, 2005 Administrators Posted September 27, 2005 Try displaying ex.StackTrace in the message box rather than message, this should give you the line in question. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
matt09524 Posted September 27, 2005 Author Posted September 27, 2005 results = dbCmd.ExecuteReader() This is what StackTrace returns. Why would this not work? Quote
matt09524 Posted September 28, 2005 Author Posted September 28, 2005 I fixed this problem. I'm 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. Quote
Administrators PlausiblyDamp Posted September 28, 2005 Administrators Posted September 28, 2005 You fixed by removing the try ... catch or you did something else and removed the try catch? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
matt09524 Posted September 29, 2005 Author Posted September 29, 2005 I fixed it BY removing the Catch-Try. I know it sounds weird. Quote
Administrators PlausiblyDamp Posted September 29, 2005 Administrators Posted September 29, 2005 Could you post the working code? It just seems odd that removing error handlers will prevent errors happening... Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.