Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Tuesday, March 20, 2012

Cannot open database requested in login ?!(help me ! )

Hi
I'm new in using "SqlClient" I have SQLSERVER 2000 on my computer and I made a Database named "TestDB", and a code like this both Using VS.net :

// begin test Code ///////////////////////////////////
string connectionString =
"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog= TestDB;Data Source=HOSSEIN-COM;Workstation ID=HOSSEIN-COM";
string commandString =
"Select * from Categories";
SqlDataAdapter DataAdapter =
new SqlDataAdapter(
commandString, connectionString);
DataSet DataSet = new DataSet( );
DataAdapter.Fill(DataSet,"CategoryID");
Label1.Text= DataSet.Tables[0].Rows[0]["CategoryID"].ToString();

// end test code /////////////////////////////////////

And at browser I found this error when I Start Building the project:

"Cannot open database requested in login 'testdb'. Login fails. Login failed for user '(my coputer name / my name )' "

Then I changed Catalog= TestDB to Catalog= Northwind and the table name to and available table name and it works , then I tried to create a table at northwind database but this error appeared :
"SELECT permission denied on object 'testTB', database 'Northwind', owner 'dbo'"
TestTB = my northwind table
I guess there must be some security setting in creating databases and tables that I do not know , And when I tried to install quick start the database was not installed ,
I have XP and VS.net and SQLserver 2000 . please halp me as You always do ;) …you need to add the user machinename/ASPNET to the db and also give select permissions to this user on the tables.

hth

Cannot open database requested by the login. The login failed.

I get that error.

I'm sure you see this question alot, but i'm dumfounded by it. Problem is that i've taken the code directly off the live website, yes i've changed the connection string...

Private _connStr As String = "Data Source=localhost\SQLEXPRESS;Initial Catalog=EFM;User ID=*****;password=******;Trusted_Connection=true"

and am using the database that was originally worked on...

Only thing that has changed is my new computer... had to reload everything... new VWD, new sql express, new sql servermanagement studio express... all semmingly working fine... ie i can see the database and edit it, i just cant connect to it through the localhost to test the program.

Any Ideas? why does this error come up... how can i fix it?

Thanks in advance

Cannot open database "EFM" requested by the login. The login failed.
Login failed for user 'GERTIE\IBM USER'.

Description:Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: Cannot open database "EFM" requested by the login. The login failed.
Login failed for user 'GERTIE\IBM USER'.

Source Error:

Line 19: MyBase.New()
Line 20: myConn = New SqlConnection(_connStr)
Line 21: myConn.Open()
Line 22: End Sub
Line 23:


Source File: C:\Documents and Settings\IBM USER\Desktop\Entertainment\wwwroot\App_Code\cDB.vb Line: 21

Stack Trace:

[SqlException (0x80131904): Cannot open database "EFM" requested by the login. The login failed.
Login failed for user 'GERTIE\IBM USER'.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +171
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +199
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2300
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +34
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +606
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +193
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +501
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +28
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +429
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +70
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +510
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +85
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +89
System.Data.SqlClient.SqlConnection.Open() +160
Datalayer.cDB..ctor() in C:\Documents and Settings\IBM USER\Desktop\Entertainment\wwwroot\App_Code\cDB.vb:21
_Default.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\IBM USER\Desktop\Entertainment\wwwroot\Default.aspx.vb:29
System.Web.UI.Control.OnLoad(EventArgs e) +80
System.Web.UI.Control.LoadRecursive() +49
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3745

Did you recreate the user in SQL? Is the system still named GERTIE? The user still exists in the new system?

Jeff

|||

the user exists in the database... no change from the proviously working version...

the system name should be irrelevant because of using localhost in the string? or is that not correct.

i don't understand what you mean by the user still exists in the new system. maybe this line of thought has something to do with it...

|||

been searching, and have never seen this issue solved...

i'm starting to get worried...

|||

Some one might be interested to know that i solved this all by myself in the end. It would appear to have somehing to do with IIS not being installed... each time this happens to someone it seems to be moving the systems accross onto a new pc... well it happens very often... I installed IIS, rebooted the pc and then unattached and then reattached the database

worked a charm!!!

Hope this helps someone some where... Oh an i want some points for this contribution!!!;)

|||

Just to be clear, IIS was installed. Otherwise you never would have received an ASP.NET error, since the file could never be processed.

Jeff

sql

Saturday, February 25, 2012

Cannot install error code is :-2147467259. Workstation Components ...

I cannot get the the workstation components to install. Below is the error.

SI (s) (C0:58) [13:25:36:394]: Note: 1: 1708
MSI (s) (C0:58) [13:25:36:394]: Product: Microsoft SQL Server "Katmai" Tools -- Installation failed.

MSI (s) (C0:58) [13:25:44:996]: Cleaning up uninstalled install packages, if any exist
MSI (s) (C0:58) [13:25:45:056]: MainEngineThread is returning 1603
MSI (s) (C0Big Smile0) [13:25:45:387]: Destroying RemoteAPI object.
MSI (s) (C0:00) [13:25:45:727]: Custom Action Manager thread ending.
=== Logging stopped: 6/4/2007 13:25:35 ===
MSI (c) (98:94) [13:25:46:047]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (98:94) [13:25:46:298]: MainEngineThread is returning 1603
=== Verbose logging stopped: 6/4/2007 13:25:46 ===

Can you log a bug on Connect and attached the error logs please. We'll take a look.

Dan Bien

SQL Setup

|||

In the machine that you installed Katmai,do you have another version of SQL Server?Because in the katmai site has a document speaking that before you install katmai,remove the workstation components of Sql Server 2005...

4.3.3 Installing SQL Server "Katmai" Removes Support for DTS in SQL Server 2005 Integration Services Packages

For this CTP release, you must uninstall SQL Server 2005 Workstation Components before installing the SQL Server "Katmai" Workstation Components. Uninstalling the SQL Server 2005 Workstation Components removes three Integration Services components: the SQL Server 2005 version of the Execute DTS 2000 Package task and two supporting assemblies. These three Integration Services components support backward compatibility between SQL Server 2005 and SQL Server 2000 Data Transformation Services (DTS). Without these three components, SQL Server 2005 packages and tools that require DTS support will not run.

However, SQL Server "Katmai" Integration Services includes a version of the Execute DTS 2000 task and the two supporting assemblies. Therefore, you can upgrade SQL Server 2005 packages that require DTS support to the SQL Server "Katmai" format by opening them in the SQL Server "Katmai" version of Business Intelligence Development Studio, and then running those packages as SQL Server "Katmai" packages.

|||

If you have not uploaded the log files yet, please see the other post on this subject:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1693821&SiteID=1

This error occurs usually due to the fact that VS is installed in a non-default location.

Max Verun

SQL Server

Cannot install error code is :-2147467259. Workstation Components ...

I cannot get the the workstation components to install. Below is the error.

SI (s) (C0:58) [13:25:36:394]: Note: 1: 1708
MSI (s) (C0:58) [13:25:36:394]: Product: Microsoft SQL Server "Katmai" Tools -- Installation failed.

MSI (s) (C0:58) [13:25:44:996]: Cleaning up uninstalled install packages, if any exist
MSI (s) (C0:58) [13:25:45:056]: MainEngineThread is returning 1603
MSI (s) (C0Big Smile0) [13:25:45:387]: Destroying RemoteAPI object.
MSI (s) (C0:00) [13:25:45:727]: Custom Action Manager thread ending.
=== Logging stopped: 6/4/2007 13:25:35 ===
MSI (c) (98:94) [13:25:46:047]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (98:94) [13:25:46:298]: MainEngineThread is returning 1603
=== Verbose logging stopped: 6/4/2007 13:25:46 ===

Can you log a bug on Connect and attached the error logs please. We'll take a look.

Dan Bien

SQL Setup

|||

In the machine that you installed Katmai,do you have another version of SQL Server?Because in the katmai site has a document speaking that before you install katmai,remove the workstation components of Sql Server 2005...

4.3.3 Installing SQL Server "Katmai" Removes Support for DTS in SQL Server 2005 Integration Services Packages

For this CTP release, you must uninstall SQL Server 2005 Workstation Components before installing the SQL Server "Katmai" Workstation Components. Uninstalling the SQL Server 2005 Workstation Components removes three Integration Services components: the SQL Server 2005 version of the Execute DTS 2000 Package task and two supporting assemblies. These three Integration Services components support backward compatibility between SQL Server 2005 and SQL Server 2000 Data Transformation Services (DTS). Without these three components, SQL Server 2005 packages and tools that require DTS support will not run.

However, SQL Server "Katmai" Integration Services includes a version of the Execute DTS 2000 task and the two supporting assemblies. Therefore, you can upgrade SQL Server 2005 packages that require DTS support to the SQL Server "Katmai" format by opening them in the SQL Server "Katmai" version of Business Intelligence Development Studio, and then running those packages as SQL Server "Katmai" packages.

|||

If you have not uploaded the log files yet, please see the other post on this subject:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1693821&SiteID=1

This error occurs usually due to the fact that VS is installed in a non-default location.

Max Verun

SQL Server

Cannot install error code is :-2147467259. Workstation Components ...

I cannot get the the workstation components to install. Below is the error.

SI (s) (C0:58) [13:25:36:394]: Note: 1: 1708
MSI (s) (C0:58) [13:25:36:394]: Product: Microsoft SQL Server "Katmai" Tools -- Installation failed.

MSI (s) (C0:58) [13:25:44:996]: Cleaning up uninstalled install packages, if any exist
MSI (s) (C0:58) [13:25:45:056]: MainEngineThread is returning 1603
MSI (s) (C0Big Smile0) [13:25:45:387]: Destroying RemoteAPI object.
MSI (s) (C0:00) [13:25:45:727]: Custom Action Manager thread ending.
=== Logging stopped: 6/4/2007 13:25:35 ===
MSI (c) (98:94) [13:25:46:047]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (98:94) [13:25:46:298]: MainEngineThread is returning 1603
=== Verbose logging stopped: 6/4/2007 13:25:46 ===

Can you log a bug on Connect and attached the error logs please. We'll take a look.

Dan Bien

SQL Setup

|||

In the machine that you installed Katmai,do you have another version of SQL Server?Because in the katmai site has a document speaking that before you install katmai,remove the workstation components of Sql Server 2005...

4.3.3 Installing SQL Server "Katmai" Removes Support for DTS in SQL Server 2005 Integration Services Packages

For this CTP release, you must uninstall SQL Server 2005 Workstation Components before installing the SQL Server "Katmai" Workstation Components. Uninstalling the SQL Server 2005 Workstation Components removes three Integration Services components: the SQL Server 2005 version of the Execute DTS 2000 Package task and two supporting assemblies. These three Integration Services components support backward compatibility between SQL Server 2005 and SQL Server 2000 Data Transformation Services (DTS). Without these three components, SQL Server 2005 packages and tools that require DTS support will not run.

However, SQL Server "Katmai" Integration Services includes a version of the Execute DTS 2000 task and the two supporting assemblies. Therefore, you can upgrade SQL Server 2005 packages that require DTS support to the SQL Server "Katmai" format by opening them in the SQL Server "Katmai" version of Business Intelligence Development Studio, and then running those packages as SQL Server "Katmai" packages.

|||

If you have not uploaded the log files yet, please see the other post on this subject:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1693821&SiteID=1

This error occurs usually due to the fact that VS is installed in a non-default location.

Max Verun

SQL Server

Friday, February 24, 2012

Cannot INSERT INTO SQL database.

I'm not sure what the problem is. I am not getting any errors, but I can't get this code to insert into my SQL db. I've checked the permissions on the database and table, and it looks fine.

Is there something wrong with this code? I'm trying to switch from VB to C#, so it's still new to me. I've used the connection string in another APP so I know it works.

If I'm not getting an asp.net error, does that point to a problem with the DB? Thanks.

protected

void Button1_Click(object sender,EventArgs e)

{

SqlConnection Conn;
SqlCommand Command;

Conn =

newSqlConnection();
Conn.ConnectionString =ConfigurationManager.AppSettings["ConnectionString"];
Command =newSqlCommand();

Command.CommandText =

"INSERT INTO [tbl_Test] ([test_name], [test_email]) VALUES (@.test_name, @.test_email)";

Command.CommandType =

CommandType.Text;
Command.Connection = Conn;
Command.Parameters.Add("test_name", tbName.Text);
Command.Parameters.Add("test_email", tbEmail.Text);try

{

Command.Connection.Open();
Command.ExecuteNonQuery();

}

catch (Exception ex)

{

lError.Text = ex.Message;

}

finally

{

Command.Connection.Close();
pSubscribe.Visible =

false;
lThanks.Visible =true;

}

Command.Parameters.Add("test_name", tbName.Text);
Command.Parameters.Add("test_email", tbEmail.Text);

should be

Command.Parameters.Add("@.test_name", tbName.Text);
Command.Parameters.Add("@.test_email", tbEmail.Text);

|||Thanks for the reply. I changed the parameters, but it still doesn't work. Any thing else I can try?|||I got it. In my SQL table, I didn't have the "identity = yes" checkbox selected for my primary key. Thanks for your help!

Thursday, February 16, 2012

Cannot get serverproperty

Using SQL2k. When I run the command below in query analyzer I get 3 columns
of info. However, when I run the same SELECT from code I get nothing. Can
anyone help? Thanks.
SELECT SERVERPROPERTY('productversion') As SQLVersion,
SERVERPROPERTY('productlevel') As ProdLevel, SERVERPROPERTY('edition') As
SQLEdition
p.s. I want to display this on a VB form. All other commands using my
connection run fine.
DavidDavid Chase (dlchase@.lifetimeinc.com) writes:
> Using SQL2k. When I run the command below in query analyzer I get 3
> columns of info. However, when I run the same SELECT from code I get
> nothing. Can anyone help? Thanks.
> SELECT SERVERPROPERTY('productversion') As SQLVersion,
> SERVERPROPERTY('productlevel') As ProdLevel, SERVERPROPERTY('edition') As
> SQLEdition
> p.s. I want to display this on a VB form. All other commands using my
> connection run fine.
It would certainly help if you posted your VB code, as it's likely
that's where the problem is.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Here is the code.
Set cn = New ADODB.Connection
cn.Open gstrSQLConString
Set rs1 = New ADODB.Recordset
Set rs1 = cn.Execute(strSQL)
strSQL = "SELECT SERVERPROPERTY('productversion') As SQLVersion," & _
" SERVERPROPERTY('productlevel') As ProdLevel," & _
" SERVERPROPERTY('edition') As SQLEdition"
Set rs1 = cn.Execute(strSQL)
If Not rs1.EOF Then
Me.txtCoAddress = CStr(rs1("SQLVersion"))
End If
David
p.s. Just above this code is an identical recordset retrieval that works
perfect.
"Erland Sommarskog" <esquel@.sommarskog.se> wrote in message
news:Xns97AA6601BD26Yazorman@.127.0.0.1...
> David Chase (dlchase@.lifetimeinc.com) writes:
> It would certainly help if you posted your VB code, as it's likely
> that's where the problem is.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server 2005 at
> http://www.microsoft.com/technet/pr...oads/books.mspx
> Books Online for SQL Server 2000 at
> http://www.microsoft.com/sql/prodin...ions/books.mspx|||David Chase (dlchase@.lifetimeinc.com) writes:
> Here is the code.
> Set cn = New ADODB.Connection
> cn.Open gstrSQLConString
> Set rs1 = New ADODB.Recordset
> Set rs1 = cn.Execute(strSQL)
> strSQL = "SELECT SERVERPROPERTY('productversion') As SQLVersion," & _
> " SERVERPROPERTY('productlevel') As ProdLevel," & _
> " SERVERPROPERTY('edition') As SQLEdition"
> Set rs1 = cn.Execute(strSQL)
> If Not rs1.EOF Then
> Me.txtCoAddress = CStr(rs1("SQLVersion"))
> End If
> David
> p.s. Just above this code is an identical recordset retrieval that works
> perfect.
Apparently, there is more to it. I tried your code in the attached
VB form, and it seemed to work fine.
Which version of ADO do you use?
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Sunday, February 12, 2012

cannot generate ResultSet code

I am using Visual Studio 2005 and SQL Server mobile edition. From Visual Studio I went to Data->Add New Data Source. From there I created and added an SQL server Mobile database. I want to use result sets instead of data sets. A file was added to my profect called: "databaseNameDataSet.xsd". In the properties for that file, when I change the Custom Tool property to MSResultSetGenerator, I get the following error:

Failed to generate ResultSet code. Typed ResultSets are only valid for Microsoft SQL Server Mobile Edition databases.

But I am using a SQL Server Mobile Edition database. Any help will be appreciated.

We have tried to do the same but everything seems to be working on our side. Can you please let us know the exact repro steps so that I can repro here locally. Also can you try doing yourself the same steps in a fresh project?

Thanks

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||I have tried starting a new project and doing it with an existing project. You asked me to tell you the steps I did, but I already told you all the steps. I did finally get it working by starting a new project and adding an example database(northwind). For some reason that worked. I think somehow when it doesn't work, is when I create a new database, and it shows up in my solution explorer and in my server explorer, but not in my data sources. Why would it not be in my data sources when I just added it using the method mentioned where I choose add new data source? Anyway, even though I don't know what I did I finally got it addded as a data source, and it is working for now.|||

Glad that things are working on your end. Thanks for using SQL Mobile.

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||i had to remove the |DataDirectory| tag in my connection string then it worked , when i add it back in the MSResultSetGenerator fails.

cannot generate ResultSet code

I am using Visual Studio 2005 and SQL Server mobile edition. From Visual Studio I went to Data->Add New Data Source. From there I created and added an SQL server Mobile database. I want to use result sets instead of data sets. A file was added to my profect called: "databaseNameDataSet.xsd". In the properties for that file, when I change the Custom Tool property to MSResultSetGenerator, I get the following error:

Failed to generate ResultSet code. Typed ResultSets are only valid for Microsoft SQL Server Mobile Edition databases.

But I am using a SQL Server Mobile Edition database. Any help will be appreciated.

We have tried to do the same but everything seems to be working on our side. Can you please let us know the exact repro steps so that I can repro here locally. Also can you try doing yourself the same steps in a fresh project?

Thanks

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||I have tried starting a new project and doing it with an existing project. You asked me to tell you the steps I did, but I already told you all the steps. I did finally get it working by starting a new project and adding an example database(northwind). For some reason that worked. I think somehow when it doesn't work, is when I create a new database, and it shows up in my solution explorer and in my server explorer, but not in my data sources. Why would it not be in my data sources when I just added it using the method mentioned where I choose add new data source? Anyway, even though I don't know what I did I finally got it addded as a data source, and it is working for now.
|||

Glad that things are working on your end. Thanks for using SQL Mobile.

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||i had to remove the |DataDirectory| tag in my connection string then it worked , when i add it back in the MSResultSetGenerator fails.

cannot generate ResultSet code

I am using Visual Studio 2005 and SQL Server mobile edition. From Visual Studio I went to Data->Add New Data Source. From there I created and added an SQL server Mobile database. I want to use result sets instead of data sets. A file was added to my profect called: "databaseNameDataSet.xsd". In the properties for that file, when I change the Custom Tool property to MSResultSetGenerator, I get the following error:

Failed to generate ResultSet code. Typed ResultSets are only valid for Microsoft SQL Server Mobile Edition databases.

But I am using a SQL Server Mobile Edition database. Any help will be appreciated.

We have tried to do the same but everything seems to be working on our side. Can you please let us know the exact repro steps so that I can repro here locally. Also can you try doing yourself the same steps in a fresh project?

Thanks

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||I have tried starting a new project and doing it with an existing project. You asked me to tell you the steps I did, but I already told you all the steps. I did finally get it working by starting a new project and adding an example database(northwind). For some reason that worked. I think somehow when it doesn't work, is when I create a new database, and it shows up in my solution explorer and in my server explorer, but not in my data sources. Why would it not be in my data sources when I just added it using the method mentioned where I choose add new data source? Anyway, even though I don't know what I did I finally got it addded as a data source, and it is working for now.
|||

Glad that things are working on your end. Thanks for using SQL Mobile.

Thanks,

Laxmi Narsimha Rao ORUGANTI, MSFT, SQL Mobile, Microsoft Corporation

|||i had to remove the |DataDirectory| tag in my connection string then it worked , when i add it back in the MSResultSetGenerator fails.