Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Thursday, March 8, 2012

Caching Application Block and SQL 2005 SQL Dependency

I am building a web app using VS2005 and SQL 2005 I would like to use the Caching Application Block to cache objects from my BLL. I was wondering if there is a way of utilizing the build in SQLDependency in SQL 2005 with the Caching Application Block? Does anybody have tried this, are there any samples on the web?

Thanks,

Newbie

You can take a look at

http://msdn2.microsoft.com/en-us/library/a52dhwx7.aspx

http://msdn2.microsoft.com/en-us/library/t9x04ed2.aspx

Friday, February 24, 2012

C# web app connection to SQL 2000

Hello, everyone,
I am trying to connect to a SQL server db with a C# app and when I debug I
get:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user
'(null)'. Reason: Not associated with a trusted SQL Server connection.
Source Error:
Line 27: if (!Page.IsPostBack)
Line 28: {
Line 29: sqlDataAdapter1.Fill(dsStudents1);
Line 30: DataGrid1.DataBind();
Line 31: }
Can somebody give me any suggestions?
Thanks,
Antonio
You are probably using the key word Integrated Security=SSPI or
trusted_connection=yes in your connection string and your Windows credential
(i.e. that of the login that runs the program) has not been granted access to
the SQL Server instance.
I'd first change Integrated Security=SSPI to user=myUser;pwd=myPassword, and
verify that there is no problem with connectivity itself (and there shouldn't
be any per your error message). Then, grant the Windows login access to the
SQL Server instance, and now you can use Integrated Security=SSPI.
Linchi
"Antonio" wrote:

> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.SqlClient.SqlException: Login failed for user
> '(null)'. Reason: Not associated with a trusted SQL Server connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>
>
|||You need to grant access to ASPNET user to your database. That is the
account that web application use.
"Antonio" <info@.awfulcards.com> wrote in message
news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.SqlClient.SqlException: Login failed for
> user '(null)'. Reason: Not associated with a trusted SQL Server
> connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>
|||The ASPNET user is setup in the database (the ASPNET user in the server, not
my machine) with access to the specific database, as owner.
"Shimon Sim" wrote:

> You need to grant access to ASPNET user to your database. That is the
> account that web application use.
> "Antonio" <info@.awfulcards.com> wrote in message
> news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
>
>
|||What is your connection string?
It is strange that user is '(null)'.
"Antonio" <Antonio@.discussions.microsoft.com> wrote in message
news:35ADEC88-2C2A-45AB-BFD9-C86607839493@.microsoft.com...[vbcol=seagreen]
> The ASPNET user is setup in the database (the ASPNET user in the server,
> not
> my machine) with access to the specific database, as owner.
> "Shimon Sim" wrote:
|||Didi you grant the appropiate rights to the service account which
starts the worker process (on *your* computer) on the SQL Server ?
Domain\ServiceAccount (Your Computer) -- > has to be prviledged on the
SQL Server
Make sure that you didn=B4t accept anonymous authentication on your
webserver.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de

C# web app connection to SQL 2000

Hello, everyone,
I am trying to connect to a SQL server db with a C# app and when I debug I
get:
Login failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user
'(null)'. Reason: Not associated with a trusted SQL Server connection.
Source Error:
Line 27: if (!Page.IsPostBack)
Line 28: {
Line 29: sqlDataAdapter1.Fill(dsStudents1);
Line 30: DataGrid1.DataBind();
Line 31: }
Can somebody give me any suggestions?
Thanks,
AntonioYou are probably using the key word Integrated Security=SSPI or
trusted_connection=yes in your connection string and your Windows credential
(i.e. that of the login that runs the program) has not been granted access t
o
the SQL Server instance.
I'd first change Integrated Security=SSPI to user=myUser;pwd=myPassword, and
verify that there is no problem with connectivity itself (and there shouldn'
t
be any per your error message). Then, grant the Windows login access to the
SQL Server instance, and now you can use Integrated Security=SSPI.
Linchi
"Antonio" wrote:

> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.SqlClient.SqlException: Login failed for us
er
> '(null)'. Reason: Not associated with a trusted SQL Server connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>
>|||You need to grant access to ASPNET user to your database. That is the
account that web application use.
"Antonio" <info@.awfulcards.com> wrote in message
news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
> Hello, everyone,
> I am trying to connect to a SQL server db with a C# app and when I debug I
> get:
> Login failed for user '(null)'. Reason: Not associated with a trusted SQL
> Server connection.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.SqlClient.SqlException: Login failed for
> user '(null)'. Reason: Not associated with a trusted SQL Server
> connection.
> Source Error:
>
> Line 27: if (!Page.IsPostBack)
> Line 28: {
> Line 29: sqlDataAdapter1.Fill(dsStudents1);
> Line 30: DataGrid1.DataBind();
> Line 31: }
>
> Can somebody give me any suggestions?
> Thanks,
>
> Antonio
>|||The ASPNET user is setup in the database (the ASPNET user in the server, not
my machine) with access to the specific database, as owner.
"Shimon Sim" wrote:

> You need to grant access to ASPNET user to your database. That is the
> account that web application use.
> "Antonio" <info@.awfulcards.com> wrote in message
> news:uMqrFT2SGHA.5884@.TK2MSFTNGP14.phx.gbl...
>
>|||What is your connection string?
It is strange that user is '(null)'.
"Antonio" <Antonio@.discussions.microsoft.com> wrote in message
news:35ADEC88-2C2A-45AB-BFD9-C86607839493@.microsoft.com...[vbcol=seagreen]
> The ASPNET user is setup in the database (the ASPNET user in the server,
> not
> my machine) with access to the specific database, as owner.
> "Shimon Sim" wrote:
>|||Didi you grant the appropiate rights to the service account which
starts the worker process (on *your* computer) on the SQL Server ?
Domain\ServiceAccount (Your Computer) -- > has to be prviledged on the
SQL Server
Make sure that you didn=B4t accept anonymous authentication on your
webserver.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--

Sunday, February 19, 2012

C# App Sql Server Express Connection Problem

I have a baffling connection problem from my C# console app to a sql
server express database.

The console application opens the sql database using the following
code:-


vDataSource = "server = " + vgSqlServer + "; " +
"database = " + vgSqlServerDb + ";" +
"uid = XXX; pwd = XXX; ";


//create the connection
vSqlConnection = new SqlConnection(vDataSource);


try
{
vSqlConnection.Open();
}
catch (Exception vSEx)
{
//connection failed
Console.WriteLine("Failed");
Console.Write("Connection Failed.\n\nError Number: " +
"\n\n" + vSEx.Message,
"Database Connection Failed");
}

The exception message is:
Request for the permission of type
'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.


I have placed the application on a network drive ( just copying it not
using publisher) and from my PC the application works fine. However
when I try to run the application from any other machine on the same
network the connection fails with an . On looking at this
message the problem appear to be because the sqlclient code cannot get permission to the database.


Both machines are using the same exe and have similar set-ups.
Other Windows applications written in C# and accessing the same database
work perfectly on both machines.


I have tried connection using both SQl Server Login id's and windows
authentication with no effect

If I publish the application to the network it appears to work perfectly!! As the application is to be called by other apps I would really like to just call the exe not the full published version


My machine has both SqlServer express manager and VS so my question
is - does anybody know of a reason why a console application will not
work on a PC where a windows application works correctly?

Sorry this is so long but I have tried to include all the details -
please ask if you need any further info.


Thanks you for your time....


DC
The Wine Society


First of all, thank you for the details, many posters just send in: I have an error message during the establishment of a connection" which is in most cases not detailed enough (*cough*cough*) to help them.

Starting your application you are running in a CAS policy problem, whereas the execution of certain libraries is NOT allowed from network drives (therefore it works when starting them locally)

See this here for more information:

http://www.devx.com/vb2themax/Article/19886

BTW: You should try to use the SQLConenctionBuilder class instead of putting your string manually together. (it included in the System.Data.SqlClient namespace)

Jens K. Suessmeyer

http://www.sqlserver2005.de

C# App Sql Server Express Connection Problem

I have a baffling connection problem from my C# console app to a sql
server express database.

The console application opens the sql database using the following
code:-


vDataSource = "server = " + vgSqlServer + "; " +
"database = " + vgSqlServerDb + ";" +
"uid = XXX; pwd = XXX; ";


//create the connection
vSqlConnection = new SqlConnection(vDataSource);


try
{
vSqlConnection.Open();
}
catch (Exception vSEx)
{
//connection failed
Console.WriteLine("Failed");
Console.Write("Connection Failed.\n\nError Number: " +
"\n\n" + vSEx.Message,
"Database Connection Failed");
}

The exception message is:
Request for the permission of type
'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089' failed.


I have placed the application on a network drive ( just copying it not
using publisher) and from my PC the application works fine. However
when I try to run the application from any other machine on the same
network the connection fails with an . On looking at this
message the problem appear to be because the sqlclient code cannot get permission to the database.


Both machines are using the same exe and have similar set-ups.
Other Windows applications written in C# and accessing the same database
work perfectly on both machines.


I have tried connection using both SQl Server Login id's and windows
authentication with no effect

If I publish the application to the network it appears to work perfectly!! As the application is to be called by other apps I would really like to just call the exe not the full published version


My machine has both SqlServer express manager and VS so my question
is - does anybody know of a reason why a console application will not
work on a PC where a windows application works correctly?

Sorry this is so long but I have tried to include all the details -
please ask if you need any further info.


Thanks you for your time....


DC
The Wine Society


First of all, thank you for the details, many posters just send in: I have an error message during the establishment of a connection" which is in most cases not detailed enough (*cough*cough*) to help them.

Starting your application you are running in a CAS policy problem, whereas the execution of certain libraries is NOT allowed from network drives (therefore it works when starting them locally)

See this here for more information:

http://www.devx.com/vb2themax/Article/19886

BTW: You should try to use the SQLConenctionBuilder class instead of putting your string manually together. (it included in the System.Data.SqlClient namespace)

Jens K. Suessmeyer

http://www.sqlserver2005.de

C# : failed due to the following error: 80040154

When i execute the following code provided by msdn, it shows error on the line Application app = newApplication().

But i got some comments that it works fine in 64-bit machine. Could you please help me out. Thanks in advance.

Executed Code

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

namespace Connections_Collection

{

classProgram

{

staticvoid Main(string[] args)

{

// The package is one of the SSIS Samples.

string mySample = @."C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";

// Create an application and load the sample.

Application app = newApplication();

Package pkg = app.LoadPackage(mySample, null);

Connections myConns = pkg.Connections;

int connCount = myConns.Count;

Console.WriteLine("The number of connections in the package is: {0}", connCount);

// Enumerate over the collection, printing out

// the values for various properties.

foreach (ConnectionManager connMgr in myConns)

{

Console.WriteLine("ConnectionString: {0}", connMgr.ConnectionString);

Console.WriteLine("CreationName: {0}", connMgr.CreationName);

Console.WriteLine("DelayValidation: {0}", connMgr.DelayValidation);

Console.WriteLine("Description: {0}", connMgr.Description);

Console.WriteLine("HostType: {0}", connMgr.HostType);

Console.WriteLine("ID: {0}", connMgr.ID);

Console.WriteLine("InnerObject: {0}", connMgr.InnerObject);

Console.WriteLine("Name: {0}", connMgr.Name);

Console.WriteLine("ProtectionLevel: {0}", connMgr.ProtectionLevel);

Console.WriteLine("SupportsDTCTransactions: {0}", connMgr.SupportsDTCTransactions);

}

Console.WriteLine("");

}

}

}

Error message

Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.

Thanks,
Kalam

I am also facing the same problem. Can anybody help on this?

the Code works fine in a 32 bit machine but shows this on a 64 bit machine.

Any idea?

Thanks in advance

|||Try to upload the DTS from a 32 bit machine onto the 64 bit and probably it should work...|||Could you elaborate on this solution please ("upload the DTS")? What is involved with uploading DTS onto Windows Vista Business 64-bit? I also get the same error message for a program running in 64-bit mode that is trying to call a 32-bit DLL. Thanks.

C# : failed due to the following error: 80040154

When i execute the following code provided by msdn, it shows error on the line Application app = new Application().

But i got some comments that it works fine in 64-bit machine. Could you please help me out. Thanks in advance.

Executed Code

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

namespace Connections_Collection

{

class Program

{

static void Main(string[] args)

{

// The package is one of the SSIS Samples.

string mySample = @."C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";

// Create an application and load the sample.

Application app = new Application();

Package pkg = app.LoadPackage(mySample, null);

Connections myConns = pkg.Connections;

int connCount = myConns.Count;

Console.WriteLine("The number of connections in the package is: {0}", connCount);

// Enumerate over the collection, printing out

// the values for various properties.

foreach (ConnectionManager connMgr in myConns)

{

Console.WriteLine("ConnectionString: {0}", connMgr.ConnectionString);

Console.WriteLine("CreationName: {0}", connMgr.CreationName);

Console.WriteLine("DelayValidation: {0}", connMgr.DelayValidation);

Console.WriteLine("Description: {0}", connMgr.Description);

Console.WriteLine("HostType: {0}", connMgr.HostType);

Console.WriteLine("ID: {0}", connMgr.ID);

Console.WriteLine("InnerObject: {0}", connMgr.InnerObject);

Console.WriteLine("Name: {0}", connMgr.Name);

Console.WriteLine("ProtectionLevel: {0}", connMgr.ProtectionLevel);

Console.WriteLine("SupportsDTCTransactions: {0}", connMgr.SupportsDTCTransactions);

}

Console.WriteLine("");

}

}

}

Error message

Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.

Thanks,
Kalam

I am also facing the same problem. Can anybody help on this?

the Code works fine in a 32 bit machine but shows this on a 64 bit machine.

Any idea?

Thanks in advance

|||Try to upload the DTS from a 32 bit machine onto the 64 bit and probably it should work...|||Could you elaborate on this solution please ("upload the DTS")? What is involved with uploading DTS onto Windows Vista Business 64-bit? I also get the same error message for a program running in 64-bit mode that is trying to call a 32-bit DLL. Thanks.

C# : failed due to the following error: 80040154

When i execute the following code provided by msdn, it shows error on the line Application app = new Application().

But i got some comments that it works fine in 64-bit machine. Could you please help me out. Thanks in advance.

Executed Code

using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.SqlServer.Dts.Runtime;

namespace Connections_Collection

{

class Program

{

static void Main(string[] args)

{

// The package is one of the SSIS Samples.

string mySample = @."C:\Program Files\Microsoft SQL Server\90\Samples\Integration Services\Package Samples\CalculatedColumns Sample\CalculatedColumns\CalculatedColumns.dtsx";

// Create an application and load the sample.

Application app = new Application();

Package pkg = app.LoadPackage(mySample, null);

Connections myConns = pkg.Connections;

int connCount = myConns.Count;

Console.WriteLine("The number of connections in the package is: {0}", connCount);

// Enumerate over the collection, printing out

// the values for various properties.

foreach (ConnectionManager connMgr in myConns)

{

Console.WriteLine("ConnectionString: {0}", connMgr.ConnectionString);

Console.WriteLine("CreationName: {0}", connMgr.CreationName);

Console.WriteLine("DelayValidation: {0}", connMgr.DelayValidation);

Console.WriteLine("Description: {0}", connMgr.Description);

Console.WriteLine("HostType: {0}", connMgr.HostType);

Console.WriteLine("ID: {0}", connMgr.ID);

Console.WriteLine("InnerObject: {0}", connMgr.InnerObject);

Console.WriteLine("Name: {0}", connMgr.Name);

Console.WriteLine("ProtectionLevel: {0}", connMgr.ProtectionLevel);

Console.WriteLine("SupportsDTCTransactions: {0}", connMgr.SupportsDTCTransactions);

}

Console.WriteLine("");

}

}

}

Error message

Retrieving the COM class factory for component with CLSID {E44847F1-FD8C-4251-B5DA-B04BB22E236E} failed due to the following error: 80040154.

Thanks,
Kalam

I am also facing the same problem. Can anybody help on this?

the Code works fine in a 32 bit machine but shows this on a 64 bit machine.

Any idea?

Thanks in advance

|||Try to upload the DTS from a 32 bit machine onto the 64 bit and probably it should work...