473,382 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

'System.NullReferenceException' Error with DB Grid

I am getting frustrated with this.
I have a winform where I doing following:
form_load:
SqlConnection objConn = new SqlConnection("Server
=(local);Database=mydatabase;uid=sa;pwd=;");
objConn.Open ();
SqlDataAdapter da = new SqlDataAdapter ("Select * from
my_table",objConn );

DataTable dt = new DataTable ("");
da.Fill ( dt);

When I run this I get following exception:
An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object

I am not able to figure out the problem
Nov 15 '05 #1
1 1091
set a break point on this line
SqlDataAdapter da = new SqlDataAdapter ("Select * from
my_table",objConn );

Use the debugger to find out if there are any errors in objConn. If it has
errors, it will be listed in the window. Then you can proceed from there
depending on whether or not there is an open error.

regards

--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits
"Dotnet_Is_Love" <lo*********@yahoo.com> wrote in message
news:35**************************@posting.google.c om...
I am getting frustrated with this.
I have a winform where I doing following:
form_load:
SqlConnection objConn = new SqlConnection("Server
=(local);Database=mydatabase;uid=sa;pwd=;");
objConn.Open ();
SqlDataAdapter da = new SqlDataAdapter ("Select * from
my_table",objConn );

DataTable dt = new DataTable ("");
da.Fill ( dt);

When I run this I get following exception:
An unhandled exception of type 'System.NullReferenceException'
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object

I am not able to figure out the problem

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DataGrid in C# | last post by:
I am having five form in C# application, after i called third party exe applicaion again im trying to goto the previous page, im getting this error in grid component. "DataGrid exception...
2
by: Raed Sawalha | last post by:
i have a windows form(Main) with listview, when click an item in listview i open other window form (Sub) which generate the selected item from parent window in as treeview items when click any item...
2
by: sxiao | last post by:
Hi, there I got a NullReferenceException when there are more than one users trying to open the same page at the same time. The senerio is: Two users logged into the web application using the...
6
by: William Mild | last post by:
I must be getting brain fried. I can't see the error. Create a new web form with the following code begind: Public Class test Inherits System.Web.UI.Page Public Class ReportCardData ...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.