DataGrid binding... small problem... help please

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: DataGrid binding... small problem... help please

    Sorry if Im wrong, but couldnt you accomplish the same thing with a JOIN?

    SELECT
    M.SSN as 'SSNfromTableM',
    M.LastName,
    P.SSN as 'SSNfromTableP'
    FROM Person P
    INNER JOIN Midn M
    ON M.SSN = P.SSN

    Even so, assigning aliases to the columns with the same name should take
    care of your problem...


    "Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    news:0f7e01c35ce7$66916030$a101280a@phx.gbl...
    > Hi. I have an SQL query which is something like this:
    >
    > SELECT M.SSN, M.lastName, P.SSN FROM Person P, Midn M
    > WHERE M.SSN = P.SSN
    >
    > In the datagrid, if I wanted to output the SSN this does
    > not work:
    > <asp:BoundColumn HeaderText="Social" DataField="SSN" />
    >
    > It says that SSN does not exist, but last name works.
    >
    > I tried:
    > <asp:BoundColumn HeaderText="Social" DataField="P.SSN" />
    >
    > and:
    > <asp:BoundColumn HeaderText="Social" DataField="M.SSN" />
    >
    > What will work? I actually need it to enter the new data
    > with something like newRow["SSN"]=... but is says that SSN
    > does not exist. Thank you so much.
    >
    > Steven

    Learning SQL Server Guest

  2. Similar Questions and Discussions

    1. Problem: Binding a datatable to RadioButtonList inside a DataGrid
      Hi, I would like to do this (see below) but keep getting error. Any help is appreciated. thanks. I have a datagrid which display a search from...
    2. problem in binding xml file data to datagrid xml file isgenerated through JSP file
      problem it that i am creating xml file using JSP file and i want to bind DataGrid with xml file data that is created using JSP but it will not Bind...
    3. Binding XML to Datagrid
      Hi, I tried to bind an XML similar to the following to a datagrid. <Idontwant> <Iwant> <Yes></Yes> <Yes></Yes> <Yes></Yes> <Yes></Yes>
    4. Binding to Datagrid
      hi friend I am developing web application in .NET using c#. I encounter a problem in binding the results to the datagrid. I have a storeprocedure...
    5. Binding a DropDownList in a DataGrid
      none of these links to INDIA work... "Saravana" <saravank@sct.co.in> wrote in message news:O0#0lqDRDHA.3796@tk2msftngp13.phx.gbl......
  3. #2

    Default Re: DataGrid binding... small problem... help please

    I need that join to be there. I know that the fields have
    the same name, which is why I named the tables P and M, so
    I could call one field P.SSN and the other one M.SSN. I
    just need to be able to output one. How can I do that?
    Thank you.
    >-----Original Message-----
    >That's because you are selecting 2 fields named SSN.
    Though presumably they
    >should be the same, since you are joining on it. You
    might as well take the
    >second one out.
    >
    >"Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    >news:0f7e01c35ce7$66916030$a101280a@phx.gbl...
    >> Hi. I have an SQL query which is something like this:
    >>
    >> SELECT M.SSN, M.lastName, P.SSN FROM Person P, Midn M
    >> WHERE M.SSN = P.SSN
    >>
    >> In the datagrid, if I wanted to output the SSN this does
    >> not work:
    >> <asp:BoundColumn HeaderText="Social" DataField="SSN" />
    >>
    >> It says that SSN does not exist, but last name works.
    >>
    >> I tried:
    >> <asp:BoundColumn HeaderText="Social"
    DataField="P.SSN" />
    >>
    >> and:
    >> <asp:BoundColumn HeaderText="Social"
    DataField="M.SSN" />
    >>
    >> What will work? I actually need it to enter the new
    data
    >> with something like newRow["SSN"]=... but is says that
    SSN
    >> does not exist. Thank you so much.
    >>
    >> Steven
    >
    >
    >.
    >
    Steven Guest

  4. #3

    Default Re: DataGrid binding... small problem... help please

    I didn't say to get rid of the join. I said to get rid of the redundant SSN
    column in your select statement.

    Since P.SSN and M.SSN are the same because of your where clause - why select
    both columns?

    If this is still not clear, I'm talking about a SQL statement like:
    SELECT M.SSN, M.lastName FROM Person P, Midn M
    WHERE M.SSN = P.SSN


    "Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    news:098d01c35cea$331ac180$a601280a@phx.gbl...
    > I need that join to be there. I know that the fields have
    > the same name, which is why I named the tables P and M, so
    > I could call one field P.SSN and the other one M.SSN. I
    > just need to be able to output one. How can I do that?
    > Thank you.
    > >-----Original Message-----
    > >That's because you are selecting 2 fields named SSN.
    > Though presumably they
    > >should be the same, since you are joining on it. You
    > might as well take the
    > >second one out.
    > >
    > >"Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    > >news:0f7e01c35ce7$66916030$a101280a@phx.gbl...
    > >> Hi. I have an SQL query which is something like this:
    > >>
    > >> SELECT M.SSN, M.lastName, P.SSN FROM Person P, Midn M
    > >> WHERE M.SSN = P.SSN
    > >>
    > >> In the datagrid, if I wanted to output the SSN this does
    > >> not work:
    > >> <asp:BoundColumn HeaderText="Social" DataField="SSN" />
    > >>
    > >> It says that SSN does not exist, but last name works.
    > >>
    > >> I tried:
    > >> <asp:BoundColumn HeaderText="Social"
    > DataField="P.SSN" />
    > >>
    > >> and:
    > >> <asp:BoundColumn HeaderText="Social"
    > DataField="M.SSN" />
    > >>
    > >> What will work? I actually need it to enter the new
    > data
    > >> with something like newRow["SSN"]=... but is says that
    > SSN
    > >> does not exist. Thank you so much.
    > >>
    > >> Steven
    > >
    > >
    > >.
    > >

    Marina Guest

  5. #4

    Default Re: DataGrid binding... small problem... help please

    Create an alias for each.

    select m.ssn as m_ssn
    , m.lastname as m_lastname
    , p.ssn as p_ssn
    from table1 M inner join table2 P on m.ssn = p.ssn

    Using the inner join will improve performance.

    Jeff
    >-----Original Message-----
    >I need that join to be there. I know that the fields
    have
    >the same name, which is why I named the tables P and M,
    so
    >I could call one field P.SSN and the other one M.SSN. I
    >just need to be able to output one. How can I do that?
    >Thank you.
    >>-----Original Message-----
    >>That's because you are selecting 2 fields named SSN.
    >Though presumably they
    >>should be the same, since you are joining on it. You
    >might as well take the
    >>second one out.
    >>
    >>"Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    >>news:0f7e01c35ce7$66916030$a101280a@phx.gbl...
    >>> Hi. I have an SQL query which is something like this:
    >>>
    >>> SELECT M.SSN, M.lastName, P.SSN FROM Person P, Midn M
    >>> WHERE M.SSN = P.SSN
    >>>
    >>> In the datagrid, if I wanted to output the SSN this
    does
    >>> not work:
    >>> <asp:BoundColumn HeaderText="Social" DataField="SSN" />
    >>>
    >>> It says that SSN does not exist, but last name works.
    >>>
    >>> I tried:
    >>> <asp:BoundColumn HeaderText="Social"
    >DataField="P.SSN" />
    >>>
    >>> and:
    >>> <asp:BoundColumn HeaderText="Social"
    >DataField="M.SSN" />
    >>>
    >>> What will work? I actually need it to enter the new
    >data
    >>> with something like newRow["SSN"]=... but is says that
    >SSN
    >>> does not exist. Thank you so much.
    >>>
    >>> Steven
    >>
    >>
    >>.
    >>
    >.
    >
    Jeff Adkins Guest

  6. #5

    Default Re: DataGrid binding... small problem... help please

    I tried this, and it said that SSNfromTableM does not
    exist. It did not like the as 'SSNfromTableM'
    and 'SSNfromTableP' statements. It would work if I
    renamed the database variables, but I have so much code to
    go through, that it would not be worth it. Is there
    another way? Why do you think the "as" statement not
    working? Thank you.
    >-----Original Message-----
    >Sorry if Im wrong, but couldnt you accomplish the same
    thing with a JOIN?
    >
    >SELECT
    >M.SSN as 'SSNfromTableM',
    >M.LastName,
    >P.SSN as 'SSNfromTableP'
    >FROM Person P
    >INNER JOIN Midn M
    >ON M.SSN = P.SSN
    >
    >Even so, assigning aliases to the columns with the same
    name should take
    >care of your problem...
    >
    >
    >"Steven" <stevenzilberman@alum.rpi.edu> wrote in message
    >news:0f7e01c35ce7$66916030$a101280a@phx.gbl...
    >> Hi. I have an SQL query which is something like this:
    >>
    >> SELECT M.SSN, M.lastName, P.SSN FROM Person P, Midn M
    >> WHERE M.SSN = P.SSN
    >>
    >> In the datagrid, if I wanted to output the SSN this does
    >> not work:
    >> <asp:BoundColumn HeaderText="Social" DataField="SSN" />
    >>
    >> It says that SSN does not exist, but last name works.
    >>
    >> I tried:
    >> <asp:BoundColumn HeaderText="Social"
    DataField="P.SSN" />
    >>
    >> and:
    >> <asp:BoundColumn HeaderText="Social"
    DataField="M.SSN" />
    >>
    >> What will work? I actually need it to enter the new
    data
    >> with something like newRow["SSN"]=... but is says that
    SSN
    >> does not exist. Thank you so much.
    >>
    >> Steven
    >
    >
    >.
    >
    Steven Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139