Re: need help

From: Mike (csharpcoder_at_sbcglobal.net)
Date: 02/24/04


Date: Tue, 24 Feb 2004 13:27:18 -0500

the sql server is local, for both my db and the pubs db which the code works
with fine.
I did change my sql to thi:

String selectCmd = "SELECT dbo.Task.tasks, dbo.Task.status,
dbo.Task.datePosted, dbo.Task.comments FROM dbo.Team INNER JOIN dbo.Task ON
dbo.Team.ID = dbo.Task.ID WHERE dbo.Task.ID = @me";

where me is the selection from the drop down. I did run this query against
the sql dbs and got the correct restuts (with the where clause hard coded.)

"Bob Boran" <mcsdsmurf@hotmail.com> wrote in message
news:ufPxuFw#DHA.1464@tk2msftngp13.phx.gbl...
> There are 2 items I can see.
> 1.) this is probably not it, but using Trusted Connections in an aspx
> application can be problematic as the User of the app is usually a
> non-trusted guest account. Is the SQL Server you are hitting a local
> install in both cases?
> 2.) your sql statement is doing a join where the ON clause is between a
> field in Task and a parameter. Shouldn't you be joining ON 2 fields, and
> whereing the parameter? We would need to see the Table Defs for the 2
> tables to give any better advice, I think.
>
>
> "Mike" <csharpcoder@sbcglobal.net> wrote in message
> news:ebGEd4v#DHA.2072@TK2MSFTNGP11.phx.gbl...
> > I have an asp.net page in C# and this code does not when I point it to
my
> > database, it works fine going against the pubs sql db but not mine
> >
> > String selectCmd = "SELECT dbo.Task.emailAddress, dbo.Task.tasks,
> > dbo.Task.datePosted, dbo.Task.comments FROM dbo.Team INNER JOIN dbo.Task
> ON
> > dbo.Team.ID = @me";
> >
> > SqlConnection myConnection = new
> >
>
SqlConnection("server=servername;database=techForum;Trusted_Connection=yes")
> > ;
> > SqlDataAdapter myCommand = new SqlDataAdapter(selectCmd, myConnection);
> >
> > myCommand.SelectCommand.Parameters.Add(new SqlParameter("@me",
> > SqlDbType.NVarChar, 2));
> > myCommand.SelectCommand.Parameters["@me"].Value =
> > MySelect.SelectedItem.Value;
> >
> > DataSet ds = new DataSet();
> > myCommand.Fill(ds, "Task");
> > MyDataGrid.DataSource= ds.Tables["Task"].DefaultView;
> > MyDataGrid.DataBind();
> >
> >
> > what it does is populate a grid depending on what the user selects in
the
> > drop down. Note: this same exact code does work when i point to the
pubs,
> or
> > nwind database, (just need to change the query.)
> >
> >
>
>



Relevant Pages

  • Re: Loads of errors when querying MS SQL Server Express 2005 from Access 2007
    ... The query below (when run through a Query Analyser connected ... diretly to the SQL server) displays the first and last name of all ... tblContactClientLinkTable.ContactID) INNER JOIN tblClient ON ...
    (comp.databases.ms-access)
  • Re: Using a parameter in a subquery
    ... Using the INNER JOIN works great! ... > Global Variables and Stored Procedure Parameters ... > the SQL statement, but maintain the entire statement dynamically. ... > Darren Green (SQL Server MVP) ...
    (microsoft.public.sqlserver.dts)
  • RE: Aggg, please check this query to see why it doesnt work
    ... SQL CE is not a server and hence doesn't support different logins and roles ... like SQL Server. ... Pronouns.Pronoun FROM Verbs INNER JOIN ... | Param 0: 1 ...
    (microsoft.public.sqlserver.ce)
  • Re: Link to table in another database
    ... creating a view which link 2 tables from 2 differents databases is very easy ... select * from DB1.dbo.Table1 A inner join SERVERB.DB2.dbo.Table2 B ... (This remote server can be "any" database server like SQL Server, Oracle, ...
    (microsoft.public.sqlserver.dts)
  • Re: No value given for one or more required parameters
    ... No this is not pubs from SQL 2000. ... There is no required filelds. ... >> Operation must use an updateable query. ...
    (microsoft.public.dotnet.languages.csharp)