Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > VB2008express edition NullReferenceExeption was unhandled
 

VB2008express edition NullReferenceExeption was unhandled

I do have a project written on XPHome in vb2008express editon which runs perfectly.However, when writing the same project on VistaUltimate32Bit it gives me this error:NullReferenceExeption was unhandled, below that line it reads this: Object reference not set to an instance of an object. next to the line in the code:
Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers).Therefore it does not load the data from the database.
Any Ideas why this is occuring? While the Datagridview on the same form will load the data just fine.The Datagridview, however is using the wizard to load the data while the for the texboxes I'm trying to use programmatically code to load the data.
Thanks
learning vb8
learningvb8  Wednesday, July 08, 2009 6:01 PM
Hi learningvb8,

This is a databinding problem which is irrelevant with WPF. I am moving it to Windows Forms Data Controls and Databinding forum.


Best regards,
Bruce Zhou
Please mark the replies as answers if they help and unmark if they don't.
Bruce.Zhou  Monday, July 13, 2009 10:24 AM

Hi learningvb8,

Based on my understanding, the data is loaded from a database and a DataTable is filled by a DataTableAdapter in your program. You used designer to add the data source and all the files related to database are generated automatically. Please feel free to tell me if I misunderstand you.

If my understanding is correct, the root cause is mostly the data base configuration. Please check the connection strings. You can find this configuration in the app.config file in the project. The xml node is configuration/connectionStrings/add, the attribute connectionString stores the connection string. The string often seems like this: "Data Source=localhost;Initial Catalog=MyDB;Integrated Security=True". In the string, you can see that the data source is localhost. So if you move this program to another machine, it would not find the database, the database is in the machine where you developed the program. To solve this problem, you need to change “localhost�to the name or network address of the instance of SQL Server in your developing machine.

You can get more help from
http://msdn.microsoft.com/en-us/library/ms254978.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx.

Let me know if this helps.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, July 14, 2009 7:36 AM

Hi,

We are changing the issue type to “General Discussion�because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question�by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Thursday, July 16, 2009 11:00 AM

You can use google to search for other answers

Custom Search

More Threads

• Datagridviewcombocolumn EndEdit event?
• Combobox Autocomplete faulty??
• How to delete Multiple rows from DGV?
• Shortcuts for windows control
• Problem with DataGridView and row deletion.
• Vertical scrollbar display corruption with bound grid when changing DataSource in Scroll event handler
• Selected and highlighted Datagridview cell
• DataGridView Image Columns
• Help! How to get a new datagridview row out of add mode?
• items list in combobox