Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataadapter .Fill no longer populates Datagrid; Stopped working

Status
Not open for further replies.

icodian

IS-IT--Management
Aug 28, 2001
74
US
I'm an amateur that used to do some simple applications in VB6 for my small business. I just upgrade to VB.NET. I was writing my first app and everything was going great. I have 3 datagrids that were populating with data perfectly when the form loads.

Then, all of a sudden, they stopped working. When I launch the app, my starting form comes up but none of the datagrids populate. No rows, nothing...just blank.

I stepped through the code and when the first dataadapter.Fill method executes, the form appears and the code stops executing completely at that point...no errors or warnings.

Notes:
1. This happened right after I added a TabControl to put the datagrids on. I don't know if that has anything to do with it or not. But removing the TabControl did not fix the problem.
2. Windows 7 Ultimate 64-bit
3. Visual Studio 2010 v10.0.40219.1 SP1Rel

I've done a little research and this is what I've done. None of these things have worked.
1. Removed the TabControl completely to see if that was causing the problem.
2. Advanced Compilation options in the Project Properties. Ensured that the Target CPU was set to x86. Changed it to AnyCPU and tested and then back to x86.
3. Put SqlConnPetVillage.Close() right before the .Fill since .Fill apparently opens the connection itself.
4. Deleted and recreated the DataGrid.

Thanks for any thoughts.
Here's the code that was working for several hours that has not changed at all:

Dim sqlBath As String
sqlBath = "SELECT sxBookID, AviClientID, AviPetId, Date, Type, LastName, FirstName, PetName, Breed, ProcID, Notes, VaccStatus, Phone1, Phone2 FROM sxBook WHERE Date = '" & newDate & "' AND Type = 1"

Dim daBath As New SqlDataAdapter(sqlBath, SqlConnPetVillage)
Dim dsBath As New DataSet

SqlConnPetVillage.Open()

daBath.Fill(dsBath, "sxBook") 'Stop executing after this line.
grdBath.DataSource = dsBath.Tables("sxBook")
 
Well, I figured it out. I feel like an idiot but I also blame VB for not telling me the problem.

I had also changed a column name in the DB from ProcID to Procedure. SQL Server had changed this to [Procedure]...I'm assuming because this is a reserved word.

What I don't understand is why VB didn't throw an error like usual. Then I would have looked more closely at the SQL Statement.

Anyway, by changing ProcID to [Procedure], the problem seems to be resolved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top