Dataset - Error

Discussion in 'MCSD' started by =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=, Jun 9, 2004.

  1. 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 se
    in the design mod

    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 = 3
    Dim DA As SqlDataAdapter = New SqlDataAdapter(
    DA.SelectCommand = selectCM

    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 erro

    Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connectio

    Can you please let me know what is causing this

    I cannot proceed with the following chapters unless I get this clear

    Many thank
    Papri Chakravorty
    =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=, Jun 9, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?UGFwcmkgQ2hha3Jhdm9ydHk=?=

    Me2 Guest

    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" <> wrote in message
    news:...
    > 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
    Me2, Jun 9, 2004
    #2
    1. Advertising

  3. Ok.
    Analyzing your connection string, I realize that you try to connect to SQL
    server which is on another machine then yours
    (your WS is CHAKP, and data source is SEAFS that mean to me that machine on
    which sql-server is running have name SEAFS) to achieve trusted connection
    and use integrated security, your two machines must be in the same domain,
    or your workstation and your server must run under win2000 server, so if it
    is not the case I recommend you to use mixed mode security (SQL and Windows)
    and put Username and Password in connection string. In case that you can
    afford trusted connection still you must impersonate your identity when
    accessing SQL server.
    Regards,
    Daniel
    "Papri Chakravorty" <> wrote in message
    news:...
    > 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
    Daniel Joskovski, Jun 9, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jacksu
    Replies:
    0
    Views:
    1,091
    jacksu
    Mar 2, 2004
  2. Ismaiel
    Replies:
    0
    Views:
    5,826
    Ismaiel
    Oct 26, 2004
  3. fullblown
    Replies:
    0
    Views:
    1,187
    fullblown
    Sep 20, 2006
  4. vbcheerful

    large dataset to xml in vb.net

    vbcheerful, Apr 9, 2008, in forum: Software
    Replies:
    0
    Views:
    1,315
    vbcheerful
    Apr 9, 2008
  5. OhioHoya

    dataset reading XML error...

    OhioHoya, Apr 26, 2010, in forum: General Computer Support
    Replies:
    0
    Views:
    1,500
    OhioHoya
    Apr 26, 2010
Loading...

Share This Page