Showing posts with label command. Show all posts
Showing posts with label command. Show all posts

Tuesday, March 20, 2012

Cant enable SQLCacheDependency

I have a SQL 2005 database and am running the 2.0 framework. I cannot seem to enable SQL caching on the db. I'm using the command line tool as follows:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql -S 99.99.999.999 -U
webteam -P sa -t tblname -d dbname -et

Enabling the table for SQL cache dependency.

.An error has happened. Details of the exception:
The database 'dbname' is not enabled for SQL cache notification
.

To enable a database for SQL cache notification, please use the System.Web.Cachi
ng.SqlCacheDependencyAdmin.EnableNotifications method, or the command line tool
aspnet_regsql. To use the tool, please run 'aspnet_regsql.exe -?' for more infor
mation.


C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

I've replaced the ip address, dbname and tblname with ficticious names for obvious reasons here in the post.

What command can I enter to enable the database for caching?

Hi,

As show on the error message, you have to enable the cache notification on the whole database, using SqlCacheDependencyAdmin.EnableNotifications() method.

I can reproduce the error on my machine. And after calling this method, aspnet_regsql works fine.

HTH. If anything is unclear, please feel free to mark this post as Not Answered and post your reply. Thanks!

|||

Kevin, I'n not sure how to use the method you described. I tried to execute it from the command line as follows, but didn't work. It looks like I need to apply it in a .net program...

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>SqlCacheDependencyAdmin.EnableNotifications(Data Source=99.99.999.999;Initial Catalog=dbname;UserID=id;Password=pswd)
'SqlCacheDependencyAdmin.EnableNotifications' is not recognized as an internal or external command,operable program or batch file.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

How should I apply this method. Thanks so much...

|||

Kevin, I'n not sure how to use the method you described. I tried to execute it from the command line as follows, but didn't work. It looks like I need to apply it in a .net program...

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>SqlCacheDependencyAdmin.EnableNotifications(Data Source=99.99.999.999;Initial Catalog=dbname;UserID=id;Password=pswd)
'SqlCacheDependencyAdmin.EnableNotifications' is not recognized as an internal or external command,operable program or batch file.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>

How should I apply this method. Thanks so much...

|||

Hi wsyeager,

This code is not executed from command line. It's a C# code.

You can create a project and execute this in the Form.Load event handler for a trial.

sql

Saturday, February 25, 2012

Can't create a BCP format file

Hi there,
does anyone know why I cannot create a bcp format file? I get
the following error. If I change the command to queryout instead of format,
it logs on OK and creates an output file. So why am I getting the error
below?
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
requested in login 'select convert(integer, p'. Login fails.
Waldy,
Please post your bcp command line. As it is, bcp apparently believes that
your login is named
'select convert(integer, p', which is surely not correct.
RLF
"Waldy" <someone@.microsoft.com> wrote in message
news:u1fydnTUIHA.5836@.TK2MSFTNGP04.phx.gbl...
> Hi there,
> does anyone know why I cannot create a bcp format file? I get
> the following error. If I change the command to queryout instead of
> format, it logs on OK and creates an output file. So why am I getting the
> error below?
> SQLState = 37000, NativeError = 4060
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open
> database requested in login 'select convert(integer, p'. Login fails.
>
|||Waldy (someone@.microsoft.com) writes:
> does anyone know why I cannot create a bcp format file? I get the
> following error. If I change the command to queryout instead of format,
> it logs on OK and creates an output file. So why am I getting the error
> below?
> SQLState = 37000, NativeError = 4060
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open
> database requested in login 'select convert(integer, p'. Login fails.
It seems to be a bug in BCP for SQL 2000. I got a similar error for this
command line:
bcp "SELECT CustomerID, COUNT(*) AS cnt FROM Northwind..Orders GROUP BY CustomerID" format xxx -f slask.fmt -T -n
with SQL 2000. With SQL 2005, the error message was more terse:
An error occurred while processing the command line.
The error in SQL 2000 actually makes sense. You are not saying QUERYOUT,
which means that what you have in the first argument is a table. But since
that database and table does not exist...
In any case, since the error message on SQL 2005 is complete crap, I
filed a bug report
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=321353
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Friday, February 24, 2012

Can't connect to the database using c# express and SQL 2005 Express

Hi

I'm trying to connect to the northwind database thats available online using c# and SQL 2005, both express editions. i used the following command

sqlcmd -S yourServer\SQLExpress -E -iinstnwnd.sql

and it connects to the northwind database. but when it comes to the part where i have to select the data source, there are only 2 available - microsoft access database file, microsoft SQL server database file. but according to the microsoft books that i'm following, there should also be a "micosoft SQL server" in the data source list. because of this i cant connect to the database.

Please help...

thank you

Please verify that you have SQL Server Installed, and it is a running service.

Go to [Control Panel], [Administrative Tools], [Services]

Look for a SQL Server service -most likely MSSQL$SQLEXPRESS

|||

hi,

all the Express version of Visual Studio only allow connections to SQL Server databases in User Instance scenario.. this is true for the VS wizards only, where you can connect to "traditional" SQL Server instance's databases via code..

regards

|||

thanks a lot guys