Showing posts with label remote. Show all posts
Showing posts with label remote. Show all posts

Tuesday, March 27, 2012

attach db

How can I attach a remote db via Enterprise Manager or Query Analyzer?
Am I wrong if I launch a "sp_attach" sql file (from my local machine) to the remote server?
Do I really have to detach local db before?
Please can someone just tell me how he did?

SaoriHi saori,
1. Did you try to post your question in the DBA section of these forums:

http://www.sqlteam.com/Forums/


http://www.sql-server-performance.com/forum/default.asp

2. Hope some DBA will help you.|||Thanks for the answer.
I'll (quickly) give it a try.

(I posted a msg there 'cause it is above all a question of method about sql server tools)

Saori|||Honestly, I attach remote db's by creating a new registration. Unless you mean something else like fiberchanneling or something, but as for having your SQL Enterprise Manager utilize a Remote SQL Server, just create a new registration.

For T-SQL based methods, you're not necessarily attaching. I'd say it's more Linked Server, or Using Remote Servers. check books online for those two in the Index tab.

SP_LinkedServers and the other method would be actually using the enterprise manager to create the registration.|||Saori,

You didn't clearly define your question about what you want to 'attach', but I think I have understood what you were saying. I would redefine your question with several possible solutions.

Assume, you have a local SQL server in your machine, and there is another SQL server in a remote machine. There is a database called pubs1 existing in the remote SQL server. You want it APPEARS ('attach') in your SQL server.

1. Logical APPEAR:
As KraGiE suggested you could make a new Server Registration in your local SQL Enterprise Manager to LINK to that remote SQL server. In this way, you would bring the whole SQL server including the pubs1 into your local SQL Enterprise Manager.

However, to do so, you need to have the access to the database, say: machine name, login name and password. It is possible that you could only access one database in that server, say, pubs1. But that is enough for you. By the way, if the remote server is not within your LAN, and need to be linked through HTTP, you should have the server IP address and also the access to possible firewall.

I called this kind of 'attach' as logical APPEARS, because the database is not physically in your machine, but still at the remote server. You can only access the database through your Enterprise Manager. The database pubs1 appearing in your Enterprise Manager is just a pointer linked to the remote server.

2. Physical APPEAR:
In short, get a physical copy from the remote server and 'attach' it to your local server.

Step 1:
Copy the database file and the log file into your local machine. In this case, pubs1 files are located by default at:
C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs1.MDF
C:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs1_log.LDF
You need shut down the remote database for copy/past, otherwise, it wouldn't work.

Step 2:
from Enterprise Manager, right click the Databases object in your local SQL instance, choose all tasks --> attach database ... . From the Attach Database window, choose your database file, pubs1, and then OK.

3. If you didn't have SQL 2000, instead of SQL 7.0, then the Step 2 would not avaiable in Enterprise Manager. You would have to use the command 'sp_attach_db' to do the job. Something like:


EXEC sp_attach_db @.dbname = N'pubs',
@.filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs1.mdf',
@.filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log1.ldf'

4. Finally, if you even didn't have SQL server 7.0, you couldn't do the trick of 'attach'. But, you could do the job with SQL server 6.5 Enterprise Manager 'Database/Object transfer' tool given you have access to the remote database, where there is equivalent tools in both SQL 7.0/2000, called Import Data/Export Data, but not as easy used as the ATTACH method.

Hope this helps.|||Thanks Phuoc, KraGiE and ghan.
This really helped me understand essential issues.

Great analysis , ghan (copied in my notepad)!
Just one little thing:
When I attach db via Enterprise Manager, do I automatically transfer log file as well?|||saori,

I am really happy to hear that. You know what, when I made some analyses to other people, I just summarize what I have done and clear my understanding about this issue myself.

When I attach db via Enterprise Manager, do I automatically transfer log file as well?

You see the example:


EXEC sp_attach_db @.dbname = N'pubs',
@.filename1 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs1.mdf',
@.filename2 = N'c:\Program Files\Microsoft SQL Server\MSSQL\Data\pubs_log1.ldf'

There are two files, one is *.mdf, the data file, another is *.ldf, the log file.

When you use enterprise manager to do the job, you will see, (at STEP 2) you only need browse the *.mdf file in, while the *.ldf file will be brought in automatically, assuming you have copied the two files into the same directory (Step 1).

Good luck.|||I have a project lets say project1. I have a copy of it running on my development server and a copy of it on my production server. I have detached db from development server and attached it to my production server. I can work in db using Enterprise manager but when I try to run my applications it doesnt work. I know why it doesnt work its because its looking for user developmentserver and now its on productionserver. Is there a way to set permissions for user productionserver without having to do every table and stored procedure one at a time? I would like to do it quickly and efficiently and doing all by hand one at a time is neither.
Please help.|||There is a security issue. You must use Windows Authentification, instead of SQL Server Authentification. You might change your connection string to use SQL Server authentification. If you want to keep to use windows authentification, you need to setup your security in your production server to make your application assistent with your SQL server.

Saturday, February 25, 2012

ASP-SQL Server Remote Connection error

Its been almost 2 months i start running a test script page to check if i made the remote connection until now its getting worst.

I did follow every bit of the instruction and pre-evaluation in fact the script is working locally with this string:

cn.Open "Driver={SQL Server};" & _
"Server=global-static-ip;" & _
"Address=local ip,1433;" & _
"Network=DBMSSOCN;" & _
"Database=testdb;" & _
"Uid=xx;" & _
"Pwd=xx;"

i also review the ff post for client and server trouble shooting tips:
http://blogs.msdn.com/sql_protocols/archive/2006/09/30/SQL-Server-2005-Remote-Connectivity-Issue-TroubleShooting.aspx

surface configuration, sql browser, firewall exemption...

and nothing seems change when i access the uploaded script.

is there anything i am missing?

by the way the script is uploaded by company.

hi,

what kind of exception are you reported with?

regards

|||Please do not double post and stick to your original posted thread.

Jens K. Suessmeyer.

http://www.sqlserver2005.de

Friday, February 24, 2012

aspnet_regiis on remote system

Sure, the subject line seems easy enough. But is there a way that I can run this tool against my local SQL 2k5 server and script out the objects it creates to try and set up the tables and what-not on a remote server that doesn't accept remote connections? Or is there maybe a pre-built script somewhere that you can point me to?

I've tried to grab the stored procs and tables under the aspnet schema and script them out but it's not working correctly. Still can't run my login form against it.

Thanks

Hello,

I think you mean aspnet_regsql.exe? If you run it on your own computer like this: aspnet_regsql.exe /? you will see all available options. In it you will read that it's possible to generate an SQL script file. You can then use this script file to create the tables.

|||

Yes, I did mean the aspnet_regsql.exe. I gen'ed the script. THanks...

Thursday, February 16, 2012

ASP.Net SQL Provider

Hello,
I am using the Visual Web Developer and would like to use the Web Site
Administration Tool to connect to a remote SQL server (it defaults to SQL
Express).
I have already run the regsql tool. My tables on my remote SQL server are
installed.
How do I add a provider in the code since I cannot do it in the GUI?
Thank you,
Exchange2003See if this helps you
www.ConnectionStrings.com
Madhivanan

Monday, February 13, 2012

ASP.Net Server Setup Exception (reqsql.exe)

I was attampting to add application services to a remote server to my ASP database and received and exception.

Setup failed.

Exception:
An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 8152 and the SqlException message is: String or binary data would be truncated.

-
Details of failure
-

SQL Server:
Database: [consecdevdb]
SQL file loaded:
InstallCommon.sql

Commands failed:

CREATE TABLE #aspnet_Permissions
(
Owner sysname,
Object sysname,
Grantee sysname,
Grantor sysname,
ProtectType char(10),
[Action] varchar(20),
[Column] sysname
)

INSERT INTO #aspnet_Permissions
EXEC sp_helprotect

IF (EXISTS (SELECT name
FROM sysobjects
WHERE (name = N'aspnet_Setup_RestorePermissions')
AND (type = 'P')))
DROP PROCEDURE [dbo].aspnet_Setup_RestorePermissions


SQL Exception:
System.Data.SqlClient.SqlException: String or binary data would be truncated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Web.Management.SqlServices.ExecuteFile(String file, String server, String database, String dbFileName, SqlConnection connection, Boolean sessionState, Boolean isInstall, SessionStateType sessionStatetype)


Can anyone help me with this?

The problem is that the "Action" column is defined as varchar(20) but it actually needs more space. Change the script to something like 200 and it should work...

Hope this helps!

-- Scott Whigham|||

Scott Whigham, This really help a lot, first I think is access problem, because i using sql to run the script, it give the error msg is

Cannot grant, deny, or revoke permissions to sa, dbo, information_schema, sys, or yourself.
Cannot grant, deny, or revoke permissions to sa, dbo, information_schema, sys, or yourself.

I keep on setting on the access right problem , still cannot solve it.

InstallCommon.SQL is default file in framework folder, how come got this kind of error?

hope microsoft can solve it....

-- Shiro Amada

ASP.Net Server Setup Exception (reqsql.exe)

I was attampting to add application services to a remote server to my ASP database and received and exception.

Setup failed.

Exception:
An error occurred during the execution of the SQL file 'InstallCommon.sql'. The SQL error number is 8152 and the SqlException message is: String or binary data would be truncated.

-
Details of failure
-

SQL Server:
Database: [consecdevdb]
SQL file loaded:
InstallCommon.sql

Commands failed:

CREATE TABLE #aspnet_Permissions
(
Owner sysname,
Object sysname,
Grantee sysname,
Grantor sysname,
ProtectType char(10),
[Action] varchar(20),
[Column] sysname
)

INSERT INTO #aspnet_Permissions
EXEC sp_helprotect

IF (EXISTS (SELECT name
FROM sysobjects
WHERE (name = N'aspnet_Setup_RestorePermissions')
AND (type = 'P')))
DROP PROCEDURE [dbo].aspnet_Setup_RestorePermissions


SQL Exception:
System.Data.SqlClient.SqlException: String or binary data would be truncated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at System.Web.Management.SqlServices.ExecuteFile(String file, String server, String database, String dbFileName, SqlConnection connection, Boolean sessionState, Boolean isInstall, SessionStateType sessionStatetype)


Can anyone help me with this?

The problem is that the "Action" column is defined as varchar(20) but it actually needs more space. Change the script to something like 200 and it should work...

Hope this helps!

-- Scott Whigham|||

Scott Whigham, This really help a lot, first I think is access problem, because i using sql to run the script, it give the error msg is

Cannot grant, deny, or revoke permissions to sa, dbo, information_schema, sys, or yourself.
Cannot grant, deny, or revoke permissions to sa, dbo, information_schema, sys, or yourself.

I keep on setting on the access right problem , still cannot solve it.

InstallCommon.SQL is default file in framework folder, how come got this kind of error?

hope microsoft can solve it....

-- Shiro Amada

Sunday, February 12, 2012

ASP.NET connection string problems with SQL Server 2000

My aspx page is trying to connect to a remote server with SQL Server 2000 installed on it, the ip of the server is 172.16.3.111 and the same is the instance of SQL Server, sql server is running in SQL Server Authentication mode, user id is "test" and password is "test123", name of database is myDB,the connection string which I am providing is as follows:

data source=172.16.3.111\172.16.3.111;user id=test;password=test123;initial catalog=myDB;"

But I am getting the following exception:

SQL Server does not exist or access denied.

even if I try the following connection string:
"data source=172.16.3.111;user id=test;password=test123;initial catalog=myDB;"

than also I get the same exception

even if provide the following connection strings:

"SERVER=172.16.3.111;UID=test;PWD=test123;DATABASE =myDB;"

"SERVER=172.16.3.111\172.16.3.111;UID=test;PWD=test123;DATABASE =myDB;"

than also I get the same exceptions

Can u please tell whats the problem,is the connection string correct,the DBA has also registered me "test" as a user on the SQL server.One thing which I want to mention is that through enterprise manager I can connect and use sql server without any problems,also please note that in VS.NET when I try connecting using server explorer and test the connection than I connect successfully, than why is problem occuring in connecting throug aspx page.

Try change the param "Server" like this:

\\ server name or server ip \ instance name

ASP.NET and SQL Server

Hello.
I have an asp.net application which currently connects to a local instance
of sql server without any issue.
When I connect to a remote sql server (same database and userid and password
are valid) there is an error indicating 'access denied.' But, when the same
code and connection strings are run on the remote server (along with the
database) the application works fine.
Connection String
user id=UserName;password=password,data source=datasource;initial
catalog=dbName
datasource\ASPNET has been added to the sql server as a user.
Any ideas? I'm using SQL Authentication and ASP.NET 1.1
Does ASP.NET run under another account when accessing a remote server?
Thanks.a) look up SetSpn
b) look up 'trust for delegation'
I bitched up a storm about this at microsoft; they don't publish this
information anywhere.
it pissed me off sooooo bad.
it's like some secret squirrel functionality in Active Directory.
-Aaron
mojo wrote:
> Hello.
> I have an asp.net application which currently connects to a local instance
> of sql server without any issue.
> When I connect to a remote sql server (same database and userid and passwo
rd
> are valid) there is an error indicating 'access denied.' But, when the sam
e
> code and connection strings are run on the remote server (along with the
> database) the application works fine.
> Connection String
> user id=UserName;password=password,data source=datasource;initial
> catalog=dbName
> datasource\ASPNET has been added to the sql server as a user.
> Any ideas? I'm using SQL Authentication and ASP.NET 1.1
> Does ASP.NET run under another account when accessing a remote server?
> Thanks.|||Since you use Username/Password pair (meaning the SQL Server's
authentication mode is mixed mode), it does not matter if you add
MachineName\ASPNET user account as a login/user to the SQL Server/database.
The other posted reply also make no sense to your problem.
Which version of QL Server do you use? SQL Server2000 or 2005? I'd look into
two things:
1. Is remote access to the SQL Server enabled? by default installation
(especially if it is SQL Server2005/Express), remote access is disabled. You
nned to explicitly enable remote access to it;
2. Double-check to make sure the SQL Server's authentication mode is mixed
mode. Again. by default installation, SQL Server uses Windows Authentication
mode (If your app indeed worked on the same computer as the SQL Server, with
the given user name and password in connectionString, then you do not need
make this check, unless the remote SQL Server is not the same SQL Server you
have tested on the same computer).
"mojo" <mojo@.discussions.microsoft.com> wrote in message
news:52A09F8F-BC9B-4DFE-B004-3D406F0B5760@.microsoft.com...
> Hello.
> I have an asp.net application which currently connects to a local instance
> of sql server without any issue.
> When I connect to a remote sql server (same database and userid and
> password
> are valid) there is an error indicating 'access denied.' But, when the
> same
> code and connection strings are run on the remote server (along with the
> database) the application works fine.
> Connection String
> user id=UserName;password=password,data source=datasource;initial
> catalog=dbName
> datasource\ASPNET has been added to the sql server as a user.
> Any ideas? I'm using SQL Authentication and ASP.NET 1.1
> Does ASP.NET run under another account when accessing a remote server?
> Thanks.
>|||Hello,
Yes, I did double check that and it is in mixed mode. I'm running SQL Server
2000 on Windows XP & ASP.NET 1.1.
Regarding remote access, where is that in SQL 2000? I don't believe I've ran
into that setting before. Do you mind pointing me in the direction of where
I
can find it?
Thanks
"Norman Yuan" wrote:

> Since you use Username/Password pair (meaning the SQL Server's
> authentication mode is mixed mode), it does not matter if you add
> MachineName\ASPNET user account as a login/user to the SQL Server/database
.
> The other posted reply also make no sense to your problem.
> Which version of QL Server do you use? SQL Server2000 or 2005? I'd look in
to
> two things:
> 1. Is remote access to the SQL Server enabled? by default installation
> (especially if it is SQL Server2005/Express), remote access is disabled. Y
ou
> nned to explicitly enable remote access to it;
> 2. Double-check to make sure the SQL Server's authentication mode is mixed
> mode. Again. by default installation, SQL Server uses Windows Authenticati
on
> mode (If your app indeed worked on the same computer as the SQL Server, wi
th
> the given user name and password in connectionString, then you do not need
> make this check, unless the remote SQL Server is not the same SQL Server y
ou
> have tested on the same computer).
> "mojo" <mojo@.discussions.microsoft.com> wrote in message
> news:52A09F8F-BC9B-4DFE-B004-3D406F0B5760@.microsoft.com...
>
>|||check
sp_configure sysytem stored procedure.
I think it might require a restart for the changes to take effect.
-Omnibuzz (The SQL GC)
http://omnibuzz-sql.blogspot.com/|||ok, I checked Remote Access and it was already set to true.
Any ideas if this issue is related to version of install (Personal v
Standard v Enterprise Edition)?
"Omnibuzz" wrote:

> check
> sp_configure sysytem stored procedure.
> I think it might require a restart for the changes to take effect.
> -Omnibuzz (The SQL GC)
> http://omnibuzz-sql.blogspot.com/
>|||Can you connect to the said SQL Server from other computers at all (you can
try to access the SQL Server from other computer by creating ODBC data
source on these computers, or create a data link file (blank text file with
extension *.udl).
If you can, then it is the problem of your ASP.NET app (assume the network
cable/hub... hardware are OK. Have you checked them?), if you cannot, it is
the problem of the SQL Server configuration.
"mojo" <mojo@.discussions.microsoft.com> wrote in message
news:D4B879EE-7CBE-4A7F-B0AD-C10DDE16685D@.microsoft.com...
> Hello,
> Yes, I did double check that and it is in mixed mode. I'm running SQL
> Server
> 2000 on Windows XP & ASP.NET 1.1.
> Regarding remote access, where is that in SQL 2000? I don't believe I've
> ran
> into that setting before. Do you mind pointing me in the direction of
> where I
> can find it?
> Thanks
> "Norman Yuan" wrote:
>

Thursday, February 9, 2012

ASP.NET 2.0 SQL Server 2005 Connect Problem

HI,

I have a standard 3 tier architecture which uses asp 2.0 and sql 2005. The SQL 2005 machine is remote and when trying connect to the db server from my logon page I get a page cannot be found once i click submit on the logon button.

I have carried out the following checks:

1 ) MAde sure that SQL Server has enabled the TCP/IP and network pipes from configuration manger.

2) I have checked that the remote connections is enabled from surface area configuration.

3) I have ensured that the network service account has privilages on the web server.

4) I am using forms authentication.

5) I have used the following connection string:

connectionString="Network Library=DBMSSOCN;Database=My_DB;data source=ServerName,1433;password=pasword;User ID=Myuser;Integrated Security=false;"

6) I have tested his connection string from a windows forms application and it s working fine.

Can someone please help me out here as I cant work out at is going wrong??

Thanks in advance

Garry

I had a similar problem a while ago, connecting to a local sql server worked fine, remote one constantly gave me an error. The only thing that seemed to work for me, for some strange reason, was to change the data source in the connection to use the server's IP address instead of the server name|||

Hi,

Since you are able to connect through windows form using the same connection, I think you need to put a breakpoint at connection.Open() method and see what the actual error is. Let me know of this so that we can pinpoint what exactly is wrong.

-Vivek

|||

Hi,

I resloved the problem. It was the fact that the WP process required db_owner rights on the SQL 2005 DB. As simple as that.

Cheers

ASP.NET 2.0 and connection to remote SQL 2000 server

Hi
I created ASP.NET 2.0 web application that uses SQL Server 2000 database and
it works perfectly when website and Sql server were on local machine.
Then I installed application on production server. Database is placed on
another server.
I received the error:
An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)
Why it thinks I am trying to connect to SQL Server 2005 ? There is no any
2005 server on remote server!
This is my connection string:
Server=servername;Database=SOX;User ID=userxxx;Password=******;
Query Analyzer and Enterprise Manager connect perfectly (when installed on
production server) to database server! Then I created small console
appplication which uses the same data layer as web application (and
connection string ) - it connected to remote database too! Only ASP.NET
2.0 application couldn't connect to remote Sql server 2000.
Can anyone help?If there is no SQL Server 2005 installed on the server then
it looks like it's hitting the wrong server. Have you tried
using the IP address?
Double check the connection string and server name in the
connection string. On the IIS server, check for aliases and
entries in the host file that could cause it to go to the
wrong server. Log onto the server where IIS is installed and
ping the SQL Server box by name. Make sure the IP address
for the SQL Server box is correct and pointing to the
correct server.
-Sue
On Sat, 5 Aug 2006 23:06:33 +0300, "Mitya Mitriev"
<aaa@.stopspam.org> wrote:

>Hi
>I created ASP.NET 2.0 web application that uses SQL Server 2000 database an
d
>it works perfectly when website and Sql server were on local machine.
>Then I installed application on production server. Database is placed on
>another server.
>I received the error:
>An error has occurred while establishing a connection to the server.
>When connecting to SQL Server 2005, this failure may be caused by the
>fact that under the default settings SQL Server does not allow remote
>connections. (provider: Named Pipes Provider, error: 40 - Could not
>open a connection to SQL Server)
>Why it thinks I am trying to connect to SQL Server 2005 ? There is no any
>2005 server on remote server!
>This is my connection string:
>Server=servername;Database=SOX;User ID=userxxx;Password=******;
>Query Analyzer and Enterprise Manager connect perfectly (when installed on
>production server) to database server! Then I created small console
>appplication which uses the same data layer as web application (and
>connection string ) - it connected to remote database too! Only ASP.NET
>2.0 application couldn't connect to remote Sql server 2000.
>Can anyone help?
>

Asp.net - SQL Server remote connection falied

Hi, I have an issue with ASP.NET 2.0 and SQL Server 2005

My project when hosted in a machine its working, but in case of some other machine it is throwing the following error

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have turned off my firewall and network configuration for sql server and its also done as tcp/ip and named pipes…though it is not working …

The surprise is if I run using IDE its running , in the same machine after hosting it is not running, where the db is in another machine. What could be the problem? Any suggestions would be highly appreciated. Regards,Naveen

Regards,

Naveen

This is usually issue with user name, password and permissions.

First did you check your connection string? You need to change server name.

Second, are you using Windows authentication or mixed mode in your SQL Server?

|||

Thanks millet, it worked when I changed the permission

|||

Hi Naveen,

Can u pls. post the changes you made. because i'm also getting this error.