Mothra Posted October 28, 2004 Posted October 28, 2004 (edited) I'm getting an intermittent error and I have no idea what is causing it. Basically, I am getting info from a database (via Stored Procedure) and putting it into a DataSet. Most of the time it works just fine. Occasionally though, one of the Columns from the database does not seem to be making it into the DataSet. The columns that I'm asking for are the same every time (there is no code selecting columns based on user choices or application conditions). Can anyone think of a reason why I would occasionally not get a certain column? Here is the code I'm using to fill the dataset... Try 'Connect to the database cn = New SqlConnection(cnStr) cn.Open() 'Set the sql command's attributes cmd = New SqlCommand("spGetCallList", cn) cmd.CommandType = CommandType.StoredProcedure 'Retrieve the data from the database da = New SqlDataAdapter(cmd) da.Fill(ds) ... 'Here is where I'm requesting the data from the column that is 'that is occasionally not showing up Dim liText As String = r.Item("CallListDesc").ToString ... Catch ex As Exception 'Inform the user of the error DisplayAlert(ex.Message) End Try To make matters worse, it is also happening in a completely unrelated method as well (exact same behavior but the errors do not happen at the exact same time...). Does anyone have any ideas? Edited October 28, 2004 by Mothra Quote Being smarter than you look is always better than looking smarter than you are.
*Experts* Nerseus Posted October 28, 2004 *Experts* Posted October 28, 2004 Maybe compare r.Item("CallListDesc") to System.DBNull.Value? I don't think you can use .ToString() on a column that contains DBNull (the equivalent of the database's null). -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Mothra Posted October 28, 2004 Author Posted October 28, 2004 No, I was taking care of the nulls in the stored procedure (ISNULL()). As it turns out, it's not my code after all. The SQL Server was having troubles so...thanks though. I do appreciate the help. Quote Being smarter than you look is always better than looking smarter than you are.
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.