Re: Dataset - Error

From: Me2 (r_at_r.com)
Date: 06/09/04


Date: Wed, 9 Jun 2004 11:44:54 -0400

This is not the last error or problem you will run into when doing the
exercise in the MS Press or other exam prep guides. You will have to start
putting your mind into developer mode, and dissecting the error messages,
and searching for an appropriate solution. If you want to become a
developer, you will do this every day of your life. So if being faced with
ambiguous error messages, and not having someone give you the answers to
everyday problems turns you off, then I suggest that you not waste any more
of your money trying to get .Net certification.

That said, lets look at what is going on.

You are getting the error:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection

So looking at this we see that it is an error coming from SQL. Second, it
is a login event. Third the user your program is trying to logon with is
'null'.

Next we would look at the connection string, which is used to "login" to SQL
server. Your connection string is:
> Dim nC As SqlConnection = New SqlConnection("data source=SEAFS;initial
catalog=Northwind;integrated security=SSPI;persist security
info=False;workstation id=CHAKP;packet size=4096")

Where in this string does it specify the userid? It does not directly.
What is does specify in regards to the userid is the
"integratedsecurity=SSPI" portion of the connection string. This specifies
that you want to use windows IIS security to control access to the SQL
server. IIS uses the ASPNET account when accessing system resources, but
you must specify that you want your application to use impersonation. You
can accomplish this by placing this string in your .config file:
<identity impersonate="true" />

Of course, you must now grant rights to ASPNET account in SQL server in
order to connect and access SQL databases and other resources.

Instead of looking for someone else to pull your fat out of the fire you
could have gone to Microsoft's Knowledge base and searched for a solution,
which you can tailor to your own system context.

-- 
Ralph Page  MBA, CMBA, MCAD .Net, MCDBA 2000, MCSE 2000, CCNA
-------------------------------------------------------------------------
"Every man is born into the world to do something unique and something
distinctive,
 and if he or she does not do it, it will never be done."
-- Dr. Benjamin E. Mays
-------------------------------------------------------------------------
"Papri Chakravorty" <anonymous@discussions.microsoft.com> wrote in message
news:C11FEF15-450C-42A0-B88D-C8184E3EF908@microsoft.com...
> Hello Experts,
>
> Yesterday I was trying to just populate a datagrid with a dataset.
> I used the following code in the page load event after using connection,
adapter and data set
> in the design mode
>
>   Dim nC As SqlConnection = New SqlConnection("data source=SEAFS;initial
catalog=Northwind;integrated security=SSPI;persist security
info=False;workstation id=CHAKP;packet size=4096")
>         Dim selectCMD As SqlCommand = New SqlCommand("SELECT CustomerID,
CompanyName FROM Customers", nC)
>         selectCMD.CommandTimeout = 30
>         Dim DA As SqlDataAdapter = New SqlDataAdapter()
>         DA.SelectCommand = selectCMD
>
>         nC.Open()
>
>         Dim DS As DataSet = New DataSet()
>         DA.Fill(DS, "Products")
>
>         nC.Close()
>
> .When i tried to build and browse,
> it gave me the following error
>
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection
>
> Can you please let me know what is causing this?
>
> I cannot proceed with the following chapters unless I get this clear.
>
> Many thanks
> Papri Chakravorty