Showing posts with label express. Show all posts
Showing posts with label express. Show all posts

Friday, March 30, 2012

Not a valid Win32 application

New to SQL Server installations. I downloaded the SQL Server Express with Advanced; when I double click the Setup.exe, I get a pop-up "document path/file is not a valid Win32 application". I upgraded from XP Home to XP Pro SP2.0. Any suggestions?Seems like the downloaded exe is corrupt. Download it again.

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Northwind database in SQL Server Express is busted and gone,after SqlCommand fails in VB2005Expr

Hi all,

I tried to use dbo.tables of Northwind database in SQL Server Express to do SqlCommand to populate a DataTable in DataSet. The SqlCommand failed in the project execution and I found that Northwind database in SQL Server Express is busted and gone (just the name "Northwind" remained in the SQL Server Management Studio Express). How can I prevent it from happening in my "SqlCommand-SqlConnection" project? Please help and advise.

I tried to repair my "Northwind" database by using the SQL2000SampleDb.msi of Northwind and pubs Sample Databases for SQL Server 2000 downloaded from the http://www.microsoft.com/downloads. My "pubs" database is still in my SQL Server Management Studio Express. How can I just repair my "Northwind" database by using the Microsoft SQL2000SampleDb.msi program? Please help and advise this matter too.

Thanks in advance,

Scott Chang

You should try to Drop or Delete the Northwind database and then recreate it from script or attach a fresh copy of the mdf file that you've download.

As to how to prevent the initial problem, you'd have to tell us what you did in the first place before anyone could offer a suggestion as to what might have gone wrong.

Mike

|||

Hi Mike, Thanks for your response.

(1). I deleted the name of "Northwind" in the SQL Server Express. Then I tried to recreate it from script by executing the following two things at the command prompt:

cd C:\SQL Server 2000 Sample Databases

sqlcmd -S .\SQLExpress -i instnwnd.sql

I got the following errors:

Changed database context to 'master'.
Msg 1802, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5170, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Cannot create file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\northwnd.ldf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 911, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1

..........................................................................................................

..........................................................................................................

Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'Territories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_Territories_Region' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'EmployeeTerritories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_EmployeeTerritories_Employees' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 3
There is already an object named 'FK_EmployeeTerritories_Territories' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 3
Could not create constraint. See previous errors.

////////////////////////////////////////////////////////////////////////////////////////////////

I think I did not delete the busted "Northwind" database in SQLExpress completely. I do not know how to attach a fresh copy of the mdf file that I have downloaded either. Please help and advise me how to resolve this problem.

(2). I feel that my "Northwind" database in SQL Server Express was busted, when I tried to run the following code statements (of my SqlBulkCopy project):

using System;

using System.Data;

using System.Data.SqlClient;

namespace SqlBulkCopySample

.........................................

.........................................

private void btnStart_Click(object sender, EventArgs e)

{

String sourceConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

String destinationConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=SqlBulkCopySample;Integrated Security=True";

DataTable data=SelectDataFromSource(sourceConnectionString);

CopyDataToDestination(destinationConnectionString, data);

}

private DataTable SelectDataFromSource(String connectionString)

{

DataTable data=new DataTable();

using (SqlConnection = new SqlConnection(connectionString))

{

SqlCommand command = new SqlCommand("SelectOrders", connection);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

SqlDataReader reader = command.ExecuteReader();

data Load(reader);

}

return data;

}

................................

...............................

/////////////////////////////////////////////////////////////////////////////////

I did not know how to create the stored procedure 'SelectOrders' in SQL Server Express yet. When I ran the SqlBulkCopySample, I got the following error:

SqlException was unhandled

Could not find stored procedure 'SelectOrders'

that were pointing to the secend staement of the following code statements:

connection.Open()

SqlDataReader reader = command.ExecuteReader();

Mike, please help again and tell me how I can prevent the "Northwind" database from being busted, if there is a mistake or wrong logic in the code statements of my ADO.NET 2.0-Visual C# 2005 Express (or VB 2005 Express) programming.

Thanks in advance,

Scott Chang

|||

OK, from the list of available database it seems that you already have the Northwind database copied to your SQL directory and attached it as a user instance. In order to recreate it from scratch, you will have to deatch the database from the user instance (by closing the application which is using it), drop the files of the Northwind database in the mentioned directory and then afterwards create the database from scratch using the script.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens, Thanks for your response and instructions.

I have a hard time to follow your instructions because I had deleted the name "Northwind" in my SQLEXPRESS already and I have the files of the Northwind database in my C:\SQL Server 2000 Sample Databases folder. I tried the two above-mentioned commands at the command prompt again and I got the same error output. Could you please help me again and give me more clearer instructions for re-installing the Northwind database?

Thanks again,

Scott Chang

|||Scott,

Kindly check whether the physical files(mdf & ldf of northwind) for Northwind db is available at "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA" path. If yes try attaching the db in SQL Express. If this option fails, then delete those files and create the db as mentioned by jens.

|||

Hi,

restart the service to make sure that no user instances are hanging around. Then see the sys.database_files to investigate if there are any database using the physical files. If not, try to attach them using a TSQL command or the SSMS Gui. if you have any further questions please come back.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens and Vidhya, Thanks for your responses and instructions.

(i) I deleted the Northwind.mdf and Northwind_log.LDF files in my C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. Then I executed the 2 commands to re-install the Northwind database. It re-installed successfully.

(ii) This morning, I ran the following project:

///////////////-Form1.vb-///////////////////

Imports System

Imports System.ComponentModel

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Text

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Windows.Forms

'

Public Class Form1

Dim bcp As SqlBulkCopy

Dim strConn As String = "Data Source=.\SQLExpress;" & _

"Initial Catalog=Northwind;Integrated Security=True"

Dim cn As New SqlConnection(strConn)

Dim options As SqlBulkCopyOptions = SqlBulkCopyOptions.Default

Dim txn As SqlTransaction = Nothing

'Supply a SqlConnction object, a value from SqlBulkCopyOptions

'and a SqlTransction object

bcp = New SqlBulkCopy(cn, options, txn)

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

End Class

//////////////////////////////////////////////////////////////////////

It did not work and I got an error "Declaration Expected" on "bcp" of

bcp = New SqlBulkCopy(cn, options, txn).

I changed that code statement as a comment {

'bcp = New SqlBulkCopy(cn, options, txn)} and then I ran it again - it ran successfully without any error mesages.

When I checked the Databases of SQL Server Management Studio Express, I found that the name "Northwind" was there only and nothing was attached to the "Northwind" database!!!! When I clicked on "Northwind", I got the following error message:

Microsoft SQL Server Management Studio Express

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional information:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

Now, my "Northwind" database in SQL Server Management Studio Express is busted again!!! I am very surprised to see this happened again. Could you please tell me why it happens and how to prevent it from happening?

Thanks,

Scott Chang

Northwind database in SQL Server Express is busted and gone,after SqlCommand fails in VB2005Expr

Hi all,

I tried to use dbo.tables of Northwind database in SQL Server Express to do SqlCommand to populate a DataTable in DataSet. The SqlCommand failed in the project execution and I found that Northwind database in SQL Server Express is busted and gone (just the name "Northwind" remained in the SQL Server Management Studio Express). How can I prevent it from happening in my "SqlCommand-SqlConnection" project? Please help and advise.

I tried to repair my "Northwind" database by using the SQL2000SampleDb.msi of Northwind and pubs Sample Databases for SQL Server 2000 downloaded from the http://www.microsoft.com/downloads. My "pubs" database is still in my SQL Server Management Studio Express. How can I just repair my "Northwind" database by using the Microsoft SQL2000SampleDb.msi program? Please help and advise this matter too.

Thanks in advance,

Scott Chang

You should try to Drop or Delete the Northwind database and then recreate it from script or attach a fresh copy of the mdf file that you've download.

As to how to prevent the initial problem, you'd have to tell us what you did in the first place before anyone could offer a suggestion as to what might have gone wrong.

Mike

|||

Hi Mike, Thanks for your response.

(1). I deleted the name of "Northwind" in the SQL Server Express. Then I tried to recreate it from script by executing the following two things at the command prompt:

cd C:\SQL Server 2000 Sample Databases

sqlcmd -S .\SQLExpress -i instnwnd.sql

I got the following errors:

Changed database context to 'master'.
Msg 1802, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5170, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Cannot create file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\northwnd.ldf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 911, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1

..........................................................................................................

..........................................................................................................

Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'Territories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_Territories_Region' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'EmployeeTerritories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_EmployeeTerritories_Employees' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 3
There is already an object named 'FK_EmployeeTerritories_Territories' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 3
Could not create constraint. See previous errors.

////////////////////////////////////////////////////////////////////////////////////////////////

I think I did not delete the busted "Northwind" database in SQLExpress completely. I do not know how to attach a fresh copy of the mdf file that I have downloaded either. Please help and advise me how to resolve this problem.

(2). I feel that my "Northwind" database in SQL Server Express was busted, when I tried to run the following code statements (of my SqlBulkCopy project):

using System;

using System.Data;

using System.Data.SqlClient;

namespace SqlBulkCopySample

.........................................

.........................................

private void btnStart_Click(object sender, EventArgs e)

{

String sourceConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

String destinationConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=SqlBulkCopySample;Integrated Security=True";

DataTable data=SelectDataFromSource(sourceConnectionString);

CopyDataToDestination(destinationConnectionString, data);

}

private DataTable SelectDataFromSource(String connectionString)

{

DataTable data=new DataTable();

using (SqlConnection = new SqlConnection(connectionString))

{

SqlCommand command = new SqlCommand("SelectOrders", connection);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

SqlDataReader reader = command.ExecuteReader();

data Load(reader);

}

return data;

}

................................

...............................

/////////////////////////////////////////////////////////////////////////////////

I did not know how to create the stored procedure 'SelectOrders' in SQL Server Express yet. When I ran the SqlBulkCopySample, I got the following error:

SqlException was unhandled

Could not find stored procedure 'SelectOrders'

that were pointing to the secend staement of the following code statements:

connection.Open()

SqlDataReader reader = command.ExecuteReader();

Mike, please help again and tell me how I can prevent the "Northwind" database from being busted, if there is a mistake or wrong logic in the code statements of my ADO.NET 2.0-Visual C# 2005 Express (or VB 2005 Express) programming.

Thanks in advance,

Scott Chang

|||

OK, from the list of available database it seems that you already have the Northwind database copied to your SQL directory and attached it as a user instance. In order to recreate it from scratch, you will have to deatch the database from the user instance (by closing the application which is using it), drop the files of the Northwind database in the mentioned directory and then afterwards create the database from scratch using the script.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens, Thanks for your response and instructions.

I have a hard time to follow your instructions because I had deleted the name "Northwind" in my SQLEXPRESS already and I have the files of the Northwind database in my C:\SQL Server 2000 Sample Databases folder. I tried the two above-mentioned commands at the command prompt again and I got the same error output. Could you please help me again and give me more clearer instructions for re-installing the Northwind database?

Thanks again,

Scott Chang

|||Scott,

Kindly check whether the physical files(mdf & ldf of northwind) for Northwind db is available at "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA" path. If yes try attaching the db in SQL Express. If this option fails, then delete those files and create the db as mentioned by jens.

|||

Hi,

restart the service to make sure that no user instances are hanging around. Then see the sys.database_files to investigate if there are any database using the physical files. If not, try to attach them using a TSQL command or the SSMS Gui. if you have any further questions please come back.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens and Vidhya, Thanks for your responses and instructions.

(i) I deleted the Northwind.mdf and Northwind_log.LDF files in my C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. Then I executed the 2 commands to re-install the Northwind database. It re-installed successfully.

(ii) This morning, I ran the following project:

///////////////-Form1.vb-///////////////////

Imports System

Imports System.ComponentModel

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Text

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Windows.Forms

'

Public Class Form1

Dim bcp As SqlBulkCopy

Dim strConn As String = "Data Source=.\SQLExpress;" & _

"Initial Catalog=Northwind;Integrated Security=True"

Dim cn As New SqlConnection(strConn)

Dim options As SqlBulkCopyOptions = SqlBulkCopyOptions.Default

Dim txn As SqlTransaction = Nothing

'Supply a SqlConnction object, a value from SqlBulkCopyOptions

'and a SqlTransction object

bcp = New SqlBulkCopy(cn, options, txn)

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

End Class

//////////////////////////////////////////////////////////////////////

It did not work and I got an error "Declaration Expected" on "bcp" of

bcp = New SqlBulkCopy(cn, options, txn).

I changed that code statement as a comment {

'bcp = New SqlBulkCopy(cn, options, txn)} and then I ran it again - it ran successfully without any error mesages.

When I checked the Databases of SQL Server Management Studio Express, I found that the name "Northwind" was there only and nothing was attached to the "Northwind" database!!!! When I clicked on "Northwind", I got the following error message:

Microsoft SQL Server Management Studio Express

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional information:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

Now, my "Northwind" database in SQL Server Management Studio Express is busted again!!! I am very surprised to see this happened again. Could you please tell me why it happens and how to prevent it from happening?

Thanks,

Scott Chang

sql

Northwind database in SQL Server Express is busted and gone,after SqlCommand fails in VB2005Expr

Hi all,

I tried to use dbo.tables of Northwind database in SQL Server Express to do SqlCommand to populate a DataTable in DataSet. The SqlCommand failed in the project execution and I found that Northwind database in SQL Server Express is busted and gone (just the name "Northwind" remained in the SQL Server Management Studio Express). How can I prevent it from happening in my "SqlCommand-SqlConnection" project? Please help and advise.

I tried to repair my "Northwind" database by using the SQL2000SampleDb.msi of Northwind and pubs Sample Databases for SQL Server 2000 downloaded from the http://www.microsoft.com/downloads. My "pubs" database is still in my SQL Server Management Studio Express. How can I just repair my "Northwind" database by using the Microsoft SQL2000SampleDb.msi program? Please help and advise this matter too.

Thanks in advance,

Scott Chang

You should try to Drop or Delete the Northwind database and then recreate it from script or attach a fresh copy of the mdf file that you've download.

As to how to prevent the initial problem, you'd have to tell us what you did in the first place before anyone could offer a suggestion as to what might have gone wrong.

Mike

|||

Hi Mike, Thanks for your response.

(1). I deleted the name of "Northwind" in the SQL Server Express. Then I tried to recreate it from script by executing the following two things at the command prompt:

cd C:\SQL Server 2000 Sample Databases

sqlcmd -S .\SQLExpress -i instnwnd.sql

I got the following errors:

Changed database context to 'master'.
Msg 1802, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5170, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Cannot create file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\northwnd.ldf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 911, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1

..........................................................................................................

..........................................................................................................

Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'Territories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_Territories_Region' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'EmployeeTerritories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_EmployeeTerritories_Employees' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 3
There is already an object named 'FK_EmployeeTerritories_Territories' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 3
Could not create constraint. See previous errors.

////////////////////////////////////////////////////////////////////////////////////////////////

I think I did not delete the busted "Northwind" database in SQLExpress completely. I do not know how to attach a fresh copy of the mdf file that I have downloaded either. Please help and advise me how to resolve this problem.

(2). I feel that my "Northwind" database in SQL Server Express was busted, when I tried to run the following code statements (of my SqlBulkCopy project):

using System;

using System.Data;

using System.Data.SqlClient;

namespace SqlBulkCopySample

.........................................

.........................................

private void btnStart_Click(object sender, EventArgs e)

{

String sourceConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

String destinationConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=SqlBulkCopySample;Integrated Security=True";

DataTable data=SelectDataFromSource(sourceConnectionString);

CopyDataToDestination(destinationConnectionString, data);

}

private DataTable SelectDataFromSource(String connectionString)

{

DataTable data=new DataTable();

using (SqlConnection = new SqlConnection(connectionString))

{

SqlCommand command = new SqlCommand("SelectOrders", connection);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

SqlDataReader reader = command.ExecuteReader();

data Load(reader);

}

return data;

}

................................

...............................

/////////////////////////////////////////////////////////////////////////////////

I did not know how to create the stored procedure 'SelectOrders' in SQL Server Express yet. When I ran the SqlBulkCopySample, I got the following error:

SqlException was unhandled

Could not find stored procedure 'SelectOrders'

that were pointing to the secend staement of the following code statements:

connection.Open()

SqlDataReader reader = command.ExecuteReader();

Mike, please help again and tell me how I can prevent the "Northwind" database from being busted, if there is a mistake or wrong logic in the code statements of my ADO.NET 2.0-Visual C# 2005 Express (or VB 2005 Express) programming.

Thanks in advance,

Scott Chang

|||

OK, from the list of available database it seems that you already have the Northwind database copied to your SQL directory and attached it as a user instance. In order to recreate it from scratch, you will have to deatch the database from the user instance (by closing the application which is using it), drop the files of the Northwind database in the mentioned directory and then afterwards create the database from scratch using the script.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens, Thanks for your response and instructions.

I have a hard time to follow your instructions because I had deleted the name "Northwind" in my SQLEXPRESS already and I have the files of the Northwind database in my C:\SQL Server 2000 Sample Databases folder. I tried the two above-mentioned commands at the command prompt again and I got the same error output. Could you please help me again and give me more clearer instructions for re-installing the Northwind database?

Thanks again,

Scott Chang

|||Scott,

Kindly check whether the physical files(mdf & ldf of northwind) for Northwind db is available at "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA" path. If yes try attaching the db in SQL Express. If this option fails, then delete those files and create the db as mentioned by jens.

|||

Hi,

restart the service to make sure that no user instances are hanging around. Then see the sys.database_files to investigate if there are any database using the physical files. If not, try to attach them using a TSQL command or the SSMS Gui. if you have any further questions please come back.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens and Vidhya, Thanks for your responses and instructions.

(i) I deleted the Northwind.mdf and Northwind_log.LDF files in my C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. Then I executed the 2 commands to re-install the Northwind database. It re-installed successfully.

(ii) This morning, I ran the following project:

///////////////-Form1.vb-///////////////////

Imports System

Imports System.ComponentModel

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Text

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Windows.Forms

'

Public Class Form1

Dim bcp As SqlBulkCopy

Dim strConn As String = "Data Source=.\SQLExpress;" & _

"Initial Catalog=Northwind;Integrated Security=True"

Dim cn As New SqlConnection(strConn)

Dim options As SqlBulkCopyOptions = SqlBulkCopyOptions.Default

Dim txn As SqlTransaction = Nothing

'Supply a SqlConnction object, a value from SqlBulkCopyOptions

'and a SqlTransction object

bcp = New SqlBulkCopy(cn, options, txn)

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

End Class

//////////////////////////////////////////////////////////////////////

It did not work and I got an error "Declaration Expected" on "bcp" of

bcp = New SqlBulkCopy(cn, options, txn).

I changed that code statement as a comment {

'bcp = New SqlBulkCopy(cn, options, txn)} and then I ran it again - it ran successfully without any error mesages.

When I checked the Databases of SQL Server Management Studio Express, I found that the name "Northwind" was there only and nothing was attached to the "Northwind" database!!!! When I clicked on "Northwind", I got the following error message:

Microsoft SQL Server Management Studio Express

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional information:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

Now, my "Northwind" database in SQL Server Management Studio Express is busted again!!! I am very surprised to see this happened again. Could you please tell me why it happens and how to prevent it from happening?

Thanks,

Scott Chang

Northwind database in SQL Server Express is busted and gone,after SqlCommand fails in VB2005Expr

Hi all,

I tried to use dbo.tables of Northwind database in SQL Server Express to do SqlCommand to populate a DataTable in DataSet. The SqlCommand failed in the project execution and I found that Northwind database in SQL Server Express is busted and gone (just the name "Northwind" remained in the SQL Server Management Studio Express). How can I prevent it from happening in my "SqlCommand-SqlConnection" project? Please help and advise.

I tried to repair my "Northwind" database by using the SQL2000SampleDb.msi of Northwind and pubs Sample Databases for SQL Server 2000 downloaded from the http://www.microsoft.com/downloads. My "pubs" database is still in my SQL Server Management Studio Express. How can I just repair my "Northwind" database by using the Microsoft SQL2000SampleDb.msi program? Please help and advise this matter too.

Thanks in advance,

Scott Chang

You should try to Drop or Delete the Northwind database and then recreate it from script or attach a fresh copy of the mdf file that you've download.

As to how to prevent the initial problem, you'd have to tell us what you did in the first place before anyone could offer a suggestion as to what might have gone wrong.

Mike

|||

Hi Mike, Thanks for your response.

(1). I deleted the name of "Northwind" in the SQL Server Express. Then I tried to recreate it from script by executing the following two things at the command prompt:

cd C:\SQL Server 2000 Sample Databases

sqlcmd -S .\SQLExpress -i instnwnd.sql

I got the following errors:

Changed database context to 'master'.
Msg 1802, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5170, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Cannot create file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\northwnd.ldf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 911, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1

..........................................................................................................

..........................................................................................................

Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'Territories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_Territories_Region' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'EmployeeTerritories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_EmployeeTerritories_Employees' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 3
There is already an object named 'FK_EmployeeTerritories_Territories' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 3
Could not create constraint. See previous errors.

////////////////////////////////////////////////////////////////////////////////////////////////

I think I did not delete the busted "Northwind" database in SQLExpress completely. I do not know how to attach a fresh copy of the mdf file that I have downloaded either. Please help and advise me how to resolve this problem.

(2). I feel that my "Northwind" database in SQL Server Express was busted, when I tried to run the following code statements (of my SqlBulkCopy project):

using System;

using System.Data;

using System.Data.SqlClient;

namespace SqlBulkCopySample

.........................................

.........................................

private void btnStart_Click(object sender, EventArgs e)

{

String sourceConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

String destinationConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=SqlBulkCopySample;Integrated Security=True";

DataTable data=SelectDataFromSource(sourceConnectionString);

CopyDataToDestination(destinationConnectionString, data);

}

private DataTable SelectDataFromSource(String connectionString)

{

DataTable data=new DataTable();

using (SqlConnection = new SqlConnection(connectionString))

{

SqlCommand command = new SqlCommand("SelectOrders", connection);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

SqlDataReader reader = command.ExecuteReader();

data Load(reader);

}

return data;

}

................................

...............................

/////////////////////////////////////////////////////////////////////////////////

I did not know how to create the stored procedure 'SelectOrders' in SQL Server Express yet. When I ran the SqlBulkCopySample, I got the following error:

SqlException was unhandled

Could not find stored procedure 'SelectOrders'

that were pointing to the secend staement of the following code statements:

connection.Open()

SqlDataReader reader = command.ExecuteReader();

Mike, please help again and tell me how I can prevent the "Northwind" database from being busted, if there is a mistake or wrong logic in the code statements of my ADO.NET 2.0-Visual C# 2005 Express (or VB 2005 Express) programming.

Thanks in advance,

Scott Chang

|||

OK, from the list of available database it seems that you already have the Northwind database copied to your SQL directory and attached it as a user instance. In order to recreate it from scratch, you will have to deatch the database from the user instance (by closing the application which is using it), drop the files of the Northwind database in the mentioned directory and then afterwards create the database from scratch using the script.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens, Thanks for your response and instructions.

I have a hard time to follow your instructions because I had deleted the name "Northwind" in my SQLEXPRESS already and I have the files of the Northwind database in my C:\SQL Server 2000 Sample Databases folder. I tried the two above-mentioned commands at the command prompt again and I got the same error output. Could you please help me again and give me more clearer instructions for re-installing the Northwind database?

Thanks again,

Scott Chang

|||Scott,

Kindly check whether the physical files(mdf & ldf of northwind) for Northwind db is available at "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA" path. If yes try attaching the db in SQL Express. If this option fails, then delete those files and create the db as mentioned by jens.

|||

Hi,

restart the service to make sure that no user instances are hanging around. Then see the sys.database_files to investigate if there are any database using the physical files. If not, try to attach them using a TSQL command or the SSMS Gui. if you have any further questions please come back.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens and Vidhya, Thanks for your responses and instructions.

(i) I deleted the Northwind.mdf and Northwind_log.LDF files in my C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. Then I executed the 2 commands to re-install the Northwind database. It re-installed successfully.

(ii) This morning, I ran the following project:

///////////////-Form1.vb-///////////////////

Imports System

Imports System.ComponentModel

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Text

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Windows.Forms

'

Public Class Form1

Dim bcp As SqlBulkCopy

Dim strConn As String = "Data Source=.\SQLExpress;" & _

"Initial Catalog=Northwind;Integrated Security=True"

Dim cn As New SqlConnection(strConn)

Dim options As SqlBulkCopyOptions = SqlBulkCopyOptions.Default

Dim txn As SqlTransaction = Nothing

'Supply a SqlConnction object, a value from SqlBulkCopyOptions

'and a SqlTransction object

bcp = New SqlBulkCopy(cn, options, txn)

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

End Class

//////////////////////////////////////////////////////////////////////

It did not work and I got an error "Declaration Expected" on "bcp" of

bcp = New SqlBulkCopy(cn, options, txn).

I changed that code statement as a comment {

'bcp = New SqlBulkCopy(cn, options, txn)} and then I ran it again - it ran successfully without any error mesages.

When I checked the Databases of SQL Server Management Studio Express, I found that the name "Northwind" was there only and nothing was attached to the "Northwind" database!!!! When I clicked on "Northwind", I got the following error message:

Microsoft SQL Server Management Studio Express

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional information:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

Now, my "Northwind" database in SQL Server Management Studio Express is busted again!!! I am very surprised to see this happened again. Could you please tell me why it happens and how to prevent it from happening?

Thanks,

Scott Chang

Northwind database in SQL Server Express is busted and gone,after SqlCommand fails in VB2005Expr

Hi all,

I tried to use dbo.tables of Northwind database in SQL Server Express to do SqlCommand to populate a DataTable in DataSet. The SqlCommand failed in the project execution and I found that Northwind database in SQL Server Express is busted and gone (just the name "Northwind" remained in the SQL Server Management Studio Express). How can I prevent it from happening in my "SqlCommand-SqlConnection" project? Please help and advise.

I tried to repair my "Northwind" database by using the SQL2000SampleDb.msi of Northwind and pubs Sample Databases for SQL Server 2000 downloaded from the http://www.microsoft.com/downloads. My "pubs" database is still in my SQL Server Management Studio Express. How can I just repair my "Northwind" database by using the Microsoft SQL2000SampleDb.msi program? Please help and advise this matter too.

Thanks in advance,

Scott Chang

You should try to Drop or Delete the Northwind database and then recreate it from script or attach a fresh copy of the mdf file that you've download.

As to how to prevent the initial problem, you'd have to tell us what you did in the first place before anyone could offer a suggestion as to what might have gone wrong.

Mike

|||

Hi Mike, Thanks for your response.

(1). I deleted the name of "Northwind" in the SQL Server Express. Then I tried to recreate it from script by executing the following two things at the command prompt:

cd C:\SQL Server 2000 Sample Databases

sqlcmd -S .\SQLExpress -i instnwnd.sql

I got the following errors:

Changed database context to 'master'.
Msg 1802, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 1
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Msg 5170, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Cannot create file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\northwnd.ldf' because it already exists. Change the file path or the file name, and retry the operation.
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 15010, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Procedure sp_dboption, Line 64
The database 'Northwind' does not exist. Use sp_helpdb to show available databases.
Available databases:
--
master
tempdb
model
msdb
ChemDatabase
ssmsExpressDB
newDB
pubs
Halloween
AdventureWorks
AdventureWorksDW
CamReynoldGISKeyR1
shcDB
C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA\NORTHWND.MDF
Msg 911, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
Could not locate entry in sysdatabases for database 'Northwind'. No entry found with that name. Make sure that the name is entered correctly.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Customers' because it is referenced by a FOREIGN KEY constraint.
Msg 3726, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not drop object 'dbo.Employees' because it is referenced by a FOREIGN KEY constraint.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 1
There is already an object named 'Employees' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'LastName' already exists on table 'dbo.Employees'.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1
The operation failed because an index or statistics with name 'PostalCode' already exists on table 'dbo.Employees'.
Msg 2714, Level 16, State 6, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'Customers' in the database.
Msg 1913, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 1

..........................................................................................................

..........................................................................................................

Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'Territories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_Territories_Region' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 1779, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Table 'EmployeeTerritories' already has a primary key defined on it.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 2
There is already an object named 'FK_EmployeeTerritories_Employees' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 2
Could not create constraint. See previous errors.
Msg 2714, Level 16, State 4, Server NAB-WK-EN\SQLEXPRESS, Line 3
There is already an object named 'FK_EmployeeTerritories_Territories' in the database.
Msg 1750, Level 16, State 1, Server NAB-WK-EN\SQLEXPRESS, Line 3
Could not create constraint. See previous errors.

////////////////////////////////////////////////////////////////////////////////////////////////

I think I did not delete the busted "Northwind" database in SQLExpress completely. I do not know how to attach a fresh copy of the mdf file that I have downloaded either. Please help and advise me how to resolve this problem.

(2). I feel that my "Northwind" database in SQL Server Express was busted, when I tried to run the following code statements (of my SqlBulkCopy project):

using System;

using System.Data;

using System.Data.SqlClient;

namespace SqlBulkCopySample

.........................................

.........................................

private void btnStart_Click(object sender, EventArgs e)

{

String sourceConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True";

String destinationConnectionString=

"Data Source=.SQLEXPRESS;Initial Catalog=SqlBulkCopySample;Integrated Security=True";

DataTable data=SelectDataFromSource(sourceConnectionString);

CopyDataToDestination(destinationConnectionString, data);

}

private DataTable SelectDataFromSource(String connectionString)

{

DataTable data=new DataTable();

using (SqlConnection = new SqlConnection(connectionString))

{

SqlCommand command = new SqlCommand("SelectOrders", connection);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

SqlDataReader reader = command.ExecuteReader();

data Load(reader);

}

return data;

}

................................

...............................

/////////////////////////////////////////////////////////////////////////////////

I did not know how to create the stored procedure 'SelectOrders' in SQL Server Express yet. When I ran the SqlBulkCopySample, I got the following error:

SqlException was unhandled

Could not find stored procedure 'SelectOrders'

that were pointing to the secend staement of the following code statements:

connection.Open()

SqlDataReader reader = command.ExecuteReader();

Mike, please help again and tell me how I can prevent the "Northwind" database from being busted, if there is a mistake or wrong logic in the code statements of my ADO.NET 2.0-Visual C# 2005 Express (or VB 2005 Express) programming.

Thanks in advance,

Scott Chang

|||

OK, from the list of available database it seems that you already have the Northwind database copied to your SQL directory and attached it as a user instance. In order to recreate it from scratch, you will have to deatch the database from the user instance (by closing the application which is using it), drop the files of the Northwind database in the mentioned directory and then afterwards create the database from scratch using the script.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens, Thanks for your response and instructions.

I have a hard time to follow your instructions because I had deleted the name "Northwind" in my SQLEXPRESS already and I have the files of the Northwind database in my C:\SQL Server 2000 Sample Databases folder. I tried the two above-mentioned commands at the command prompt again and I got the same error output. Could you please help me again and give me more clearer instructions for re-installing the Northwind database?

Thanks again,

Scott Chang

|||Scott,

Kindly check whether the physical files(mdf & ldf of northwind) for Northwind db is available at "C:\PROGRAM FILES\MICROSOFT SQL SERVER\MSSQL.1\MSSQL\DATA" path. If yes try attaching the db in SQL Express. If this option fails, then delete those files and create the db as mentioned by jens.

|||

Hi,

restart the service to make sure that no user instances are hanging around. Then see the sys.database_files to investigate if there are any database using the physical files. If not, try to attach them using a TSQL command or the SSMS Gui. if you have any further questions please come back.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

Hi Jens and Vidhya, Thanks for your responses and instructions.

(i) I deleted the Northwind.mdf and Northwind_log.LDF files in my C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data folder. Then I executed the 2 commands to re-install the Northwind database. It re-installed successfully.

(ii) This morning, I ran the following project:

///////////////-Form1.vb-///////////////////

Imports System

Imports System.ComponentModel

Imports System.Data

Imports System.Data.SqlClient

Imports System.Data.SqlTypes

Imports System.Text

Imports System.Collections.Generic

Imports System.Drawing

Imports System.Windows.Forms

'

Public Class Form1

Dim bcp As SqlBulkCopy

Dim strConn As String = "Data Source=.\SQLExpress;" & _

"Initial Catalog=Northwind;Integrated Security=True"

Dim cn As New SqlConnection(strConn)

Dim options As SqlBulkCopyOptions = SqlBulkCopyOptions.Default

Dim txn As SqlTransaction = Nothing

'Supply a SqlConnction object, a value from SqlBulkCopyOptions

'and a SqlTransction object

bcp = New SqlBulkCopy(cn, options, txn)

Public Sub New()

' This call is required by the Windows Form Designer.

InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

End Class

//////////////////////////////////////////////////////////////////////

It did not work and I got an error "Declaration Expected" on "bcp" of

bcp = New SqlBulkCopy(cn, options, txn).

I changed that code statement as a comment {

'bcp = New SqlBulkCopy(cn, options, txn)} and then I ran it again - it ran successfully without any error mesages.

When I checked the Databases of SQL Server Management Studio Express, I found that the name "Northwind" was there only and nothing was attached to the "Northwind" database!!!! When I clicked on "Northwind", I got the following error message:

Microsoft SQL Server Management Studio Express

Failed to retrieve data for this request. (Microsoft.SqlServer.Express.SmoEnum)

Additional information:

One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup. (Microsoft SQL Server, Error: 5173)

Now, my "Northwind" database in SQL Server Management Studio Express is busted again!!! I am very surprised to see this happened again. Could you please tell me why it happens and how to prevent it from happening?

Thanks,

Scott Chang

Friday, March 23, 2012

Noob question about SQL Server Express used local and on server.

I have just started looking at using a database with my web site. If I have SQL Server Express with the Advanced Services on my local machine and I use it to make interactive pages, can I use the schema and tables on the actual web site on a remote server? If so does that server need to have SQL Server Express installed too?

A link to a tutorial or reference that goes into some detail would be awsome!

Thanks everyone!

Yes, you will need SQL Express and the Advanced Services installed on the server. Depending on how you have it setup, you should just be able to copy the contents of th App_Data folder over and it should work. This page should provide further information:http://msdn2.microsoft.com/en-us/library/ms165668.aspx

Tuesday, March 20, 2012

Nonconvergence issue after upgrading MSDE to SQL 2005 Express

I'm experiencing an intermittent issue with merge replication after
upgrading one of the subscribers to SQL 2005 Express from MSDE 2000.
Here are a few details about the environment before I describe the
issue
1. Originally was SQL 2000 Standard Publisher with MSDE 2000
Subscribers all SP4
2. Upgraded (in place) Publisher to SQL 2005 Standard SP1 - no issues
3. Upgraded 1 of 3 subscribers to SQL 2005 Express SP1 encountered the
following issue only on the upgraded Express installation
4. Merge replication is running continuously as a pull subscription
with column-level tracking
5. Replication is running as a scheduled task on the subscriber (pull)
by executing replmerg.exe
Issue:
Background: A contacts table has addresses stored in a separate table
with the address_id in the contacts table referencing the address_id
in the addresses table
1. Contact created on subscriber without an address (null address_id)
2. Replication runs (contact uploaded to publisher)
3. Contact updated at subscriber to have an address (address_id
populated)
4. Replication uploads changes to publisher
4a. The address is uploaded to the publisher
4b. The address_id update to the contact record appears to be uploaded
to the publisher (confirmed by running SQL profiler)
4c. After the replication session is complete the address_id update to
the contact record appears to have not been made or is rolled back
5. Replication downloads changes to the subscriber and determines that
the address is not part of the partition for the subscriber (because
the address_id is not present in the contact record) and removes it
from the subscriber (the address is still present on publisher)
If I were to bet on a theory about why the address_id update to the
contact record is getting lost I would put my money on a deadlock (or
similar issue) and rollback but I would be interested to hear if
anyone has run into similar issues. I'd also be interested to know why
SQL 2005 Express would behave differently when replicating than MSDE
2000 (this setup has been running for almost 2 years on the MSDE with
no issues). If it is a deadlock/rollback then does the MSDE subscriber
handle the rollback differently than the Express subscriber? Is there
a re-try step that is not running in Express that does run in MSDE?
Have you logged to an output file or run profiler to determine exactly what
is happening?
If it is a deadlock the merge agent is transactional in nature and will put
the error in a retry loop at the end of each batch.
So this doesn't really explain what you are seeing.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Brian Fell" <brianfell@.gmail.com> wrote in message
news:1182807685.623799.115710@.u2g2000hsc.googlegro ups.com...
> I'm experiencing an intermittent issue with merge replication after
> upgrading one of the subscribers to SQL 2005 Express from MSDE 2000.
> Here are a few details about the environment before I describe the
> issue
> 1. Originally was SQL 2000 Standard Publisher with MSDE 2000
> Subscribers all SP4
> 2. Upgraded (in place) Publisher to SQL 2005 Standard SP1 - no issues
> 3. Upgraded 1 of 3 subscribers to SQL 2005 Express SP1 encountered the
> following issue only on the upgraded Express installation
> 4. Merge replication is running continuously as a pull subscription
> with column-level tracking
> 5. Replication is running as a scheduled task on the subscriber (pull)
> by executing replmerg.exe
>
> Issue:
> Background: A contacts table has addresses stored in a separate table
> with the address_id in the contacts table referencing the address_id
> in the addresses table
> 1. Contact created on subscriber without an address (null address_id)
> 2. Replication runs (contact uploaded to publisher)
> 3. Contact updated at subscriber to have an address (address_id
> populated)
> 4. Replication uploads changes to publisher
> 4a. The address is uploaded to the publisher
> 4b. The address_id update to the contact record appears to be uploaded
> to the publisher (confirmed by running SQL profiler)
> 4c. After the replication session is complete the address_id update to
> the contact record appears to have not been made or is rolled back
> 5. Replication downloads changes to the subscriber and determines that
> the address is not part of the partition for the subscriber (because
> the address_id is not present in the contact record) and removes it
> from the subscriber (the address is still present on publisher)
>
> If I were to bet on a theory about why the address_id update to the
> contact record is getting lost I would put my money on a deadlock (or
> similar issue) and rollback but I would be interested to hear if
> anyone has run into similar issues. I'd also be interested to know why
> SQL 2005 Express would behave differently when replicating than MSDE
> 2000 (this setup has been running for almost 2 years on the MSDE with
> no issues). If it is a deadlock/rollback then does the MSDE subscriber
> handle the rollback differently than the Express subscriber? Is there
> a re-try step that is not running in Express that does run in MSDE?
>
|||On Jun 25, 10:06 pm, "Hilary Cotter" <hilary.cot...@.gmail.com> wrote:
> Have you logged to an output file or run profiler to determine exactly what
> is happening?
> If it is a deadlock the merge agent is transactional in nature and will put
> the error in a retry loop at the end of each batch.
> So this doesn't really explain what you are seeing.
> --
> Looking for a SQL Server replication book?http://www.nwsu.com/0974973602.html
> Looking for a FAQ on Indexing Services/SQL FTShttp://www.indexserverfaq.com"Brian Fell" <brianf...@.gmail.com> wrote in message
> news:1182807685.623799.115710@.u2g2000hsc.googlegro ups.com...
>
>
>
>
> - Show quoted text -
I ran profiler and saw no evidence of any problem however I do see the
update with the address_id in it (and an entry that indicated that
replication thought the upload was successful (Uploaded 2 change(s) in
''contacts'' (1 insert, 1 update) - one of those for the address entry
as well). Unfortunately, it took me three weeks to catch this thing
with profiler and I didn't have the replication logging to a file when
I started it up that day (was switching back and forth between
watching the console and reviewing a log). Any ideas about something
to look at would be greatly appreciated.
Thanks,
Brian Fell
|||You will probably have to try to repro the problem using the specific set of
commands you outline in your original post.
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Brian Fell" <brianfell@.gmail.com> wrote in message
news:1182824624.031896.140300@.o61g2000hsh.googlegr oups.com...
> On Jun 25, 10:06 pm, "Hilary Cotter" <hilary.cot...@.gmail.com> wrote:
> I ran profiler and saw no evidence of any problem however I do see the
> update with the address_id in it (and an entry that indicated that
> replication thought the upload was successful (Uploaded 2 change(s) in
> ''contacts'' (1 insert, 1 update) - one of those for the address entry
> as well). Unfortunately, it took me three weeks to catch this thing
> with profiler and I didn't have the replication logging to a file when
> I started it up that day (was switching back and forth between
> watching the console and reviewing a log). Any ideas about something
> to look at would be greatly appreciated.
> Thanks,
> Brian Fell
>

Saturday, February 25, 2012

No way to save database diagram outside of database?

This is to express my frustration that there's apparently no way to save a database diagram outside of the database that it's diagramming.

Like many developers, we maintain our databases under source control as SQL scripts. When we need to install the database, we just run the scripts to build the database, from scratch, no need to save any binaries.

I recently took the time to create a database diagram for one of our existing databases, using the tool in Management Studio (2005). For starters, the diagram editor is a primitive toy that lacks many obvious features. But now I that I have the diagram, I find I've painted myself into a corner: The next time I want to build the database from script, I'll lose the diagram, because as far as I can tell, it's persisted as a BLOB in a system table.

I thought maybe I would be able to right-click on the diagram and that I would find an option to "Save diagram to script", or something like that, but the closest I get is "Copy diagram to clipboard" [as a bitmap]. I could save the bitmap, but this leaves me with something I can't maintain.

I might suggest that the Visual Database Tools team take a look at the Visual Studio class diagrams. The editor for these is also a rather primitive toy, but at least the diagrams are persisted as XML, so you can save the diagram script as text in source control, and if you need the diagram to look better than the designer will do on its own, you can edit the code.

Thanks for your consideration. If there is a way to do what I want that I've overlooked, I would appreciate if someone would let me know.

-Allan

1. Insert the rows in dbo.sysdiagrams into a common dev database before you script a new database then reinsert them into a newly created sysdiagrams table when you create a database from the script.

2. Use Visio

|||

Sorry to hear you are unhappy with the database diagram. We've had a number of suggestions filed on Microsoft Connect to improve this area: http://connect.microsoft.com/SQLServer/feedback/SearchResults.aspx?SearchQuery=diagram.

Take a look through those and vote on the issues that are important to you. If you feel there are issues another customer hasn't filed, submit a new suggestion and we'll take it into consideration.

Paul A. Mestemaker II
Program Manager
Microsoft SQL Server Manageability
http://blogs.msdn.com/sqlrem/

Monday, February 20, 2012

No support for SQL Express or SQL Developer edition running on Virtual PC?

Am I miss-reading something? After spending hours upon hours trying to install VS2005 Beta 2 June CTP edition, I stumbled across some documentation that basically says that SQL Express is *not* supported running on a Virtual PC.

Has anyone else run into this problem?

This is the documentation that I found:
http://download.microsoft.com/download/9/9/5/99599cc4-93ee-4252-85dd-23abff8631b0/RequirementsSQLEXP2005.htm
SQL Express will work fine on Virtual PC.

No SS2005 Express

I have SS 2005 express* working(yrs) on a XP home ver. laptop. I got a new Acer w/ Vista hm/premium and I registered/can't get SS 2005 express* to download from MSDN.

Norton's gives a file block, I click the 'download file' and nothing happens. No dialog, hd drv activity, nothing - just 'Done'

on IE7 status. I have Visual Web Developer beta v2 2008** running on the Acer and don't want to trash the install.

.NET fwrk v2.0 is listed required for SS2005, but .NET fwrk v3.5 says it includes v2.0 + WCF,...(right? - install both?)

I need a SS for VWD 2008. I've ask/tried several times. What am I doing wrong?

Mark

There are no blocks of any kind on the site that would prevent you from downloading the installer package for SQL Express, it's just a simple file download. The download does not check for anything at all. You should investigate if you have anything configured about Norton or Windows (IE?) that is stopping the download of certain types of files.

Mike

No SS2005 Express

I have SS 2005 express* working(yrs) on a XP home ver. laptop. I got a new Acer w/ Vista hm/premium and I registered/can't get SS 2005 express* to download from MSDN.

Norton's gives a file block, I click the 'download file' and nothing happens. No dialog, hd drv activity, nothing - just 'Done'

on IE7 status. I have Visual Web Developer beta v2 2008** running on the Acer and don't want to trash the install.

.NET fwrk v2.0 is listed required for SS2005, but .NET fwrk v3.5 says it includes v2.0 + WCF,...(right? - install both?)

I need a SS for VWD 2008. I've ask/tried several times. What am I doing wrong?

Mark

There are no blocks of any kind on the site that would prevent you from downloading the installer package for SQL Express, it's just a simple file download. The download does not check for anything at all. You should investigate if you have anything configured about Norton or Windows (IE?) that is stopping the download of certain types of files.

Mike