Showing posts with label associated. Show all posts
Showing posts with label associated. Show all posts

Friday, February 24, 2012

Accessing value from SqlDataSource

I have a SqlDataSource that returns a list of companies and their details by ProductID. It also returns the name of the product associated with the ProductID as the final column (which means it appears for every record returned). I already have a way of determining how many rows were returned, and use that information in a label to say "Your search has returnedx records".

protected void dsGetSuppliersByProduct_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
int RecordCount = e.AffectedRows;
if (RecordCount == 0)
{ lblRecordCount.Text = "<p>No Records found"; }
else
{
if (RecordCount == 1)
{ lblRecordCount.Text = "<p>Your search returned 1 record"; }
else
{ lblRecordCount.Text = "<p>Your search returned " + RecordCount + " records"; }
}
string ProductName;
}

How can I access the ProductName value so that I can extend the label text to say "Your search has returnedx records for <ProductName>" ?

I found a way to do what I wanted. I changed the label to a literal control (for display purposes) and accessed the ProductName value in the RowDataBound event. I then applied it to another literal. My first go resulted in the ProductName appearing as many times as there were rows, so I checked to see if the Literal.Text had already been assigned. So now my code looks like this:

protected void dsGetSuppliersByProduct_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
int RecordCount = e.AffectedRows;
if (RecordCount == 0)
{ ltRecordCount.Text = "<p>No Records found"; }
else
{
if (RecordCount == 1)
{ ltRecordCount.Text = "<p>1 supplier"; }
else
{ ltRecordCount.Text = "<p>" + RecordCount + " suppliers"; }

}

}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string pName = DataBinder.Eval(e.Row.DataItem, "ProductName").ToString();
if (ltProductName.Text == "")
{
ltProductName.Text = " of <strong>" + pName + "</strong></p>";
}
}
}

Thursday, February 16, 2012

accessing SQL Server behind a firewall

I am trying to get to an instance of SQL Server behind a
firewall via port 1450, but I get an error message : "Not
associated with a trusted SQL Server Connection". Do I
need to use a different port? Somehow register port 1450?
Port 1433 is being used for a SQL Server instance on
another machine.sounds like you're trying to use windows authentication and it can't get
through the firewall.
jjjjj wrote:
> I am trying to get to an instance of SQL Server behind a
> firewall via port 1450, but I get an error message : "Not
> associated with a trusted SQL Server Connection". Do I
> need to use a different port? Somehow register port 1450?
> Port 1433 is being used for a SQL Server instance on
> another machine.|||No, I'm using SQL Server authentication. I can get to the
default database fine. There seems to be an issue with
using port 1450.
>--Original Message--
>sounds like you're trying to use windows authentication
and it can't get
>through the firewall.
>
>jjjjj wrote:
>> I am trying to get to an instance of SQL Server behind a
>> firewall via port 1450, but I get an error
message : "Not
>> associated with a trusted SQL Server Connection". Do I
>> need to use a different port? Somehow register port
1450?
>> Port 1433 is being used for a SQL Server instance on
>> another machine.
>.
>|||Is it a named or default instance? Use Server Network Utility to check port numbers.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"jjjjj" <anonymous@.discussions.microsoft.com> wrote in message
news:4a0301c4a186$995460f0$a501280a@.phx.gbl...
>I am trying to get to an instance of SQL Server behind a
> firewall via port 1450, but I get an error message : "Not
> associated with a trusted SQL Server Connection". Do I
> need to use a different port? Somehow register port 1450?
> Port 1433 is being used for a SQL Server instance on
> another machine.|||It is a default instance on the machine but not the
firewall default instance.
>--Original Message--
>Is it a named or default instance? Use Server Network
Utility to check port numbers.
>--
>Tibor Karaszi, SQL Server MVP
>http://www.karaszi.com/sqlserver/default.asp
>http://www.solidqualitylearning.com/
>
>"jjjjj" <anonymous@.discussions.microsoft.com> wrote in
message
>news:4a0301c4a186$995460f0$a501280a@.phx.gbl...
>>I am trying to get to an instance of SQL Server behind a
>> firewall via port 1450, but I get an error
message : "Not
>> associated with a trusted SQL Server Connection". Do I
>> need to use a different port? Somehow register port
1450?
>> Port 1433 is being used for a SQL Server instance on
>> another machine.
>
>.
>|||Hi
It should not make an difference if there is another instance on another
server.
Ports are opened with a IP address:Port combination. You can have a 1000 SQL
servers, all using the same port number, as long as each server has a
different IP address.
Regards
Mike
"jjjjj" wrote:
> I am trying to get to an instance of SQL Server behind a
> firewall via port 1450, but I get an error message : "Not
> associated with a trusted SQL Server Connection". Do I
> need to use a different port? Somehow register port 1450?
> Port 1433 is being used for a SQL Server instance on
> another machine.
>|||> It is a default instance on the machine but not the
> firewall default instance.
I'm sorry, but I didn't get that. What is a "firewall default instance"?
I think Mike's post gives you the information you need. Find out what port number your SQL server
uses (again, use Server Network Utility). Then open in the firewall for that IP Address and port
number combination.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"jjjjj" <anonymous@.discussions.microsoft.com> wrote in message
news:19da01c4a18e$a365eb10$a401280a@.phx.gbl...
> It is a default instance on the machine but not the
> firewall default instance.
> >--Original Message--
> >Is it a named or default instance? Use Server Network
> Utility to check port numbers.
> >
> >--
> >Tibor Karaszi, SQL Server MVP
> >http://www.karaszi.com/sqlserver/default.asp
> >http://www.solidqualitylearning.com/
> >
> >
> >"jjjjj" <anonymous@.discussions.microsoft.com> wrote in
> message
> >news:4a0301c4a186$995460f0$a501280a@.phx.gbl...
> >>I am trying to get to an instance of SQL Server behind a
> >> firewall via port 1450, but I get an error
> message : "Not
> >> associated with a trusted SQL Server Connection". Do I
> >> need to use a different port? Somehow register port
> 1450?
> >> Port 1433 is being used for a SQL Server instance on
> >> another machine.
> >
> >
> >.
> >