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" <love_dotnet@yahoo.com> wrote in message
news:35a0aa74.0310291228.27892061@posting.google.c om...[color=blue]
> 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[/color]