Showing posts with label establish. Show all posts
Showing posts with label establish. Show all posts

Monday, March 26, 2012

Establishing a remote connection..!

How can I establish a remote connection for using remote database in SQL Server 2K5?

Thanks.

Take a look at this link:

http://msdn2.microsoft.com/en-us/library(d=robot)/ms188721.aspx

Is this what you are looking for? If not, please provide additional information on the scenario you want to enable.

Thanks
Laurentiu

|||

my scenario :

my computer is into a LAN. I want to connect from my PC to a database on another computer in this LAN. I have username and password for logging in to the another computer in SQL Server Authentication mode.

please help me!

|||

How did you try to connect so far?

Normally, you would need to specify the server name, and the user name and password. But you should check that the server accepts remote connections and that you're not blocked by a firewall. Also check to see that the type of connection that you make is enabled on the server (if you use TCP, check that TCP is enabled).

Thanks
Laurentiu

sql

Establish SQL Connection

Hi! (my first post)

I'm ASP.NET newbie and i´ve got anSQL connection error, i know why, ididn´t establish a connection...
my questions are: how do i establish the connection state?, and where in my project should i do it?

I added the connection section to my web.config, is that enough to establish a connection?

<connectionStrings>
<add name="buscomConnectionString" connectionString="Data Source=myserver.net;Initial Catalog=mycatalog;Persist Security Info=True;User ID=myuser;Password=mypassword"
providerName="System.Data.SqlClient" />
</connectionStrings>

The error i get is:

Object reference not set to an instance of an object.

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

Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 2443:
Line 2444://If connection is not open then attempt to open it.
Line 2445:if (connection.State == System.Data.ConnectionState.Closed)
Line 2446:{
Line 2447:try


Source File: d:\User\buscom\App_Code\PHP.cs Line: 2445

Thanks and cheers!

Bill Murphy (litio.net)

Welcome to ASP.NET ForumsSmile The section you added in web.config is just to store a conneciton string which then can be used in your application. You can create a connection using the connection string like:

SqlConnection conn= new SqlConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString.ToString());

Then use Open method to open it:

Conn.Open();

Or you can create a SqlCommand with the connection:

SqlCommand cmd= new SqlCommand("SELECT * FROM sysobjects",conn);

Or do other things as you like. To learn various database connections in ASP .NET, you can start from here:

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

However I suggest you use 'using' block to embed database operations so that the connection will be automatically disposed, so to avoid leaving unuseful open connections. That is:

using (SqlConnection conn= new SqlConnection(ConfigurationManager.ConnectionStrings["Access"].ConnectionString.ToString()))

{//add your code

}

To learn more about connection Close/Dispose in .NET, you can take a look at this article:

http://codebetter.com/blogs/sahil.malik/archive/2004/12/31/40036.aspx

|||

That was what I was looking for!! just didn´t seem to find it :D
Both link where very helpfull.

Thanks a lot!

|||

sorry, buy looking into that didn´t work out. i have to reopen my question...

I am using the PHPMigration assistant, so i went ahead and generated the connect command and got the following:

try {PHP.MSSQLSupport.Connect(host, user, password); }

catch(System.Exception) {Response.Write("Error, no server"); }

try {PHP.MSSQLSupport.ChangeDatabas
________________________________________________________

This is a duplicate of your other post:http://forums.asp.net/thread/1387576.aspx

Duplicate posts are not permitted on theASP.NET Forums. As a result, the duplicate post has been deleted. We trust however that you will receive helpful replies to your other post, linked above.

Please be aware that theASP.NET Forums are moderated. This means that there will always be a delay between submitting a message and seeing it appear on the forums. There is no need to submit a message multiple times.

Thanks,
ASP.NET Forums team

",0]);//-->e(bbdd);}

catch (System.Exception) { Response.Write( bbdd + " not found"); }

Inserted it into my page and the error above persists.

i am passing a null to PHP.MSSQLSupport.Query, that should reopen the last connection, so i guessI'm just not opening the connection as i should...

How should iestablish the connection with the PHPMigration assistant generatedcode? should i remove the info on the web. config or the above lines?

should i mention my connection string name ( buscomConnectionString )anywhere in the code? or should the above code be enough?

if the databese isn´t connecting properly, would i get a different error? (maybe Error, no server as i specified??)

|||This is what i meant to post:

sorry, buy looking into that didn´t work out. i have to reopen my question...

I am using the PHPMigration assistant, so i went ahead and generated the connect command and got the following:

try {PHP.MSSQLSupport.Connect(host, user, password); }

catch(System.Exception) {Response.Write("Error, no server"); }

try {PHP.MSSQLSupport.ChangeDatabase(bbdd);}

catch (System.Exception) { Response.Write( bbdd + " not found"); }

Inserted it into my page and the error above persists.

i am passing a null to PHP.MSSQLSupport.Query, that should reopen the last connection, so i guessI'm just not opening the connection as i should...

How should iestablish the connection with the PHPMigration assistant generatedcode? should i remove the info on the web. config or the above lines?

should i mention my connection string name ( buscomConnectionString )anywhere in the code? or should the above code be enough?

if the databese isn´t connecting properly, would i get a different error? (maybe Error, no server as i specified??)

Establish log dhipping db in sql2005

Hi all
I have db on my log shipping server as standby\readonly and my transaction log
was out of sync, I would like to make full bak from the source server and
restore
on log shipping server but when I right click the db in sql manager studio
the RESTORE database option DIM out. I can do this with sql 2000 to
reestablish
db when my transaction log was out of sync but look like I can't do this
with sql 2005. Have i missed any thing here?
Please help
Thanks in advancedfrank
Personally I have not played yet with it on SQL Server 2005 , but can you
issue BACKUP/RESTORE in the query builder instead of SSMS?
"frank" <frank@.discussions.microsoft.com> wrote in message
news:752AC215-1833-4B97-B57C-2E52C646D6BF@.microsoft.com...
> Hi all
> I have db on my log shipping server as standby\readonly and my transaction
> log
> was out of sync, I would like to make full bak from the source server and
> restore
> on log shipping server but when I right click the db in sql manager studio
> the RESTORE database option DIM out. I can do this with sql 2000 to
> reestablish
> db when my transaction log was out of sync but look like I can't do this
> with sql 2005. Have i missed any thing here?
> Please help
> Thanks in advanced

Establish log dhipping db in sql2005

Hi all
I have db on my log shipping server as standby\readonly and my transaction log
was out of sync, I would like to make full bak from the source server and
restore
on log shipping server but when I right click the db in sql manager studio
the RESTORE database option DIM out. I can do this with sql 2000 to
reestablish
db when my transaction log was out of sync but look like I can't do this
with sql 2005. Have i missed any thing here?
Please help
Thanks in advanced
frank
Personally I have not played yet with it on SQL Server 2005 , but can you
issue BACKUP/RESTORE in the query builder instead of SSMS?
"frank" <frank@.discussions.microsoft.com> wrote in message
news:752AC215-1833-4B97-B57C-2E52C646D6BF@.microsoft.com...
> Hi all
> I have db on my log shipping server as standby\readonly and my transaction
> log
> was out of sync, I would like to make full bak from the source server and
> restore
> on log shipping server but when I right click the db in sql manager studio
> the RESTORE database option DIM out. I can do this with sql 2000 to
> reestablish
> db when my transaction log was out of sync but look like I can't do this
> with sql 2005. Have i missed any thing here?
> Please help
> Thanks in advanced

Establish log dhipping db in sql2005

Hi all
I have db on my log shipping server as standby\readonly and my transaction l
og
was out of sync, I would like to make full bak from the source server and
restore
on log shipping server but when I right click the db in sql manager studio
the RESTORE database option DIM out. I can do this with sql 2000 to
reestablish
db when my transaction log was out of sync but look like I can't do this
with sql 2005. Have i missed any thing here?
Please help
Thanks in advancedfrank
Personally I have not played yet with it on SQL Server 2005 , but can you
issue BACKUP/RESTORE in the query builder instead of SSMS?
"frank" <frank@.discussions.microsoft.com> wrote in message
news:752AC215-1833-4B97-B57C-2E52C646D6BF@.microsoft.com...
> Hi all
> I have db on my log shipping server as standby\readonly and my transaction
> log
> was out of sync, I would like to make full bak from the source server and
> restore
> on log shipping server but when I right click the db in sql manager studio
> the RESTORE database option DIM out. I can do this with sql 2000 to
> reestablish
> db when my transaction log was out of sync but look like I can't do this
> with sql 2005. Have i missed any thing here?
> Please help
> Thanks in advanced

establish duplicate logs

i've got a table like this...
date connected disconnected
10/02/2005 10:03:33 10:05:34
10/02/2005 14:11:00 15:22:01
10/02/2005 14:30 15:00:00
how can i check what connections overlapped in sql?
e.g. result would be (connected at the same time):
10/02/2005 14:11:00 15:22:01
10/02/2005 14:30 15:00:00Nemo
Look at this example ( it will give an idea) written by Itzik Ben-Gan
create table tblConnection
(
StartTimeCon datetime not null,
EndTimeCon datetime not null
)
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
10:00','20000610 10:10')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
10:20','20000610 10:22')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
10:23','20000610 10:25')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
10:27','20000610 10:45')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
11:57','20000610 12:00')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
12:01','20000610 12:04')
insert into tblConnection(StartTimeCon,EndTimeCon)va
lues ('20000610
12:04','20000610 12:40')
select * from tblConnection
SELECT
StartTimeCon,
ISNULL(
(SELECT MIN(EndTimeCon)
FROM tblConnection AS S3
WHERE S3.StartTimeCon >= S1.StartTimeCon
AND ISNULL(
DATEDIFF(
minute,
S3.EndTimeCon,
(SELECT MIN(StartTimeCon)
FROM tblConnection AS S4
WHERE S4.StartTimeCon > S3.EndTimeCon)), 5) >= 5),
EndTimeCon) AS EndTimeCon
FROM tblConnection AS S1
WHERE ISNULL(
DATEDIFF(
minute,
(SELECT MAX(EndTimeCon)
FROM tblConnection AS S2
WHERE S2.EndTimeCon < S1.StartTimeCon),S1.StartTimeCon),5) >= 5
"Nemo" <blogmeester@.gmail.com> wrote in message
news:dcqljb$6qs$2@.ctb-nnrp2.saix.net...
> i've got a table like this...
> date connected disconnected
> 10/02/2005 10:03:33 10:05:34
> 10/02/2005 14:11:00 15:22:01
> 10/02/2005 14:30 15:00:00
> how can i check what connections overlapped in sql?
>
> e.g. result would be (connected at the same time):
> 10/02/2005 14:11:00 15:22:01
> 10/02/2005 14:30 15:00:00
>
>
>|||Try,
What format are you using for column [date]?
Is there any primary key in this table that we can use to uniquely identify
each row?

> 10/02/2005
Example:
use northwind
go
create table t1 (
pk_col int not null identity primary key,
[date] varchar(10),
connected char(8),
disconnected char(8)
)
go
insert into t1([date], connected, disconnected) values('10/02/2005',
'10:03:33', '10:05:34')
insert into t1([date], connected, disconnected) values('10/02/2005',
'14:11:00', '15:22:01')
insert into t1([date], connected, disconnected) values('10/02/2005',
'14:30:00', '15:00:00')
go
select * from t1
go
create view dbo.v1
as
select
pk_col, [date], connected, disconnected,
cast(right([date], 4) + '-' + left([date], 2) + '-' + substring([date],
4, 2) + 'T' + connected as datetime) as c1,
cast(right([date], 4) + '-' + left([date], 2) + '-' + substring([date],
4, 2) + 'T' + disconnected as datetime) as c2
from t1
go
select
[date], connected, disconnected
from
dbo.v1 as a
where
exists(select * from dbo.v1 as b where a.pk_col != b.pk_col and a.c1 <=
b.c2 and a.c2 >= b.c1)
or
exists(select * from dbo.v1 as b where a.pk_col != b.pk_col and b.c1 <=
a.c2 and b.c2 >= a.c1)
go
drop view dbo.v1
go
drop table t1
go
AMB
"Nemo" wrote:

> i've got a table like this...
> date connected disconnected
> 10/02/2005 10:03:33 10:05:34
> 10/02/2005 14:11:00 15:22:01
> 10/02/2005 14:30 15:00:00
> how can i check what connections overlapped in sql?
>
> e.g. result would be (connected at the same time):
> 10/02/2005 14:11:00 15:22:01
> 10/02/2005 14:30 15:00:00
>
>
>|||On Wed, 3 Aug 2005 16:50:18 +0200, Nemo wrote:

>i've got a table like this...
>date connected disconnected
>10/02/2005 10:03:33 10:05:34
>10/02/2005 14:11:00 15:22:01
>10/02/2005 14:30 15:00:00
>how can i check what connections overlapped in sql?
>
>e.g. result would be (connected at the same time):
>10/02/2005 14:11:00 15:22:01
>10/02/2005 14:30 15:00:00
Hi Nemo,
Storing date and time in seperate columns is actually not a good idea.
What if a connection begins before midnight, but ends after midnight?
And what if the time between connecting and disconnecting is more than
24 hours?
If you remove the seperate date column and store connected and
disconnected as datetime values, the query to find the overlaps is easy:
SELECT a.connected, a.disconnected
FROM MyTable AS a
WHERE EXISTS
(SELECT *
FROM MyTable AS b
WHERE b.disconnected > a.connected
AND b.connected < a.disconnected)
Depending on your definition of overlap, you might have to change the <
and > operators to <= and >=.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||thanks, followed the advice.
Will combine the date and time fields.
think my table structures nneed some work
regards
Nemo
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:evb2f1db2obpa231qjk858633q1gvnccj8@.
4ax.com...
> On Wed, 3 Aug 2005 16:50:18 +0200, Nemo wrote:
>
> Hi Nemo,
> Storing date and time in seperate columns is actually not a good idea.
> What if a connection begins before midnight, but ends after midnight?
> And what if the time between connecting and disconnecting is more than
> 24 hours?
> If you remove the seperate date column and store connected and
> disconnected as datetime values, the query to find the overlaps is easy:
> SELECT a.connected, a.disconnected
> FROM MyTable AS a
> WHERE EXISTS
> (SELECT *
> FROM MyTable AS b
> WHERE b.disconnected > a.connected
> AND b.connected < a.disconnected)
> Depending on your definition of overlap, you might have to change the <
> and > operators to <= and >=.
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)sql

Establish connection to the server

Hi,

I have a problem editing my SQL databases in Visual Studio 2005, i have searched the web for answers, but those were not clear enough to me, somthing about changing my settings for SQL server, but i didn't follow it all to well, the current error mesage I get when i click in the Server Explorer on my data connections is:

An error has occured 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 do have followed some tips, bit end to this error mesage every time. Bevore i followed that tips the error said:

(provider: TCP/IP, error ... i dont remember anymore...)

I have tried to delete SQL and Visual Studio but it didn't help, and reinstall it.

Please can somebody help me, i am realy fFrustrated about the fact i cant fix it!By default SQL Server Express does not have remote connections enabled. You can do this using the following instructions: http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx|||Yes, i have seen these instructions before, and i apply them again. But again without any succes. the error i now get is:

Connecting to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkId=49251

I downloaded the file, open it. It recognizes the Named Instance as SQLExpress but then it said:

Name: Microsoft SQL Server 2005 Express Edition (SQLEXPRESS)

Allowed Action: Maintain (Action is only available from Add or Remove Programs)

Reason: Cannot maintain product, to maintain the product go to Add or Remove Programs

And the things i have in my Add or Remove Programs are:

Microsoft SQL Server 2005
Microsoft SQL Server 2005 Mobile
Microsoft SQL Server Native Client
Microsoft SQL Server Settup supporting files
Microsoft SQL Server VSS writer

What must i do?

|||

I encountered the same error message while trying to create a data connection from Visual Studio 2005 using the Server Explorer.

This is what I did:

# 1. Started Visual Studio 2005

# 2. Opened the Server Explorer (View | Server Explorer)

# 3. Right-clicked the Data Connections node

# 4. Selected Create New SQL Server Database... from the context menu

# 5. Selected my computer from the Server Name dropdown list

# 6. Selected authentication method (Use Windows Authentication)

# 7. Typed a name in the New Database Name field

# 8. Hit the OK button

That's when I received the following error message

An error has occured 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)

It made absolutely no sense. I wasn't trying to connect to a remote computer. I was simply trying to connect to the SQL Server 2005 Express Edition which was installed on my local computer during the Visual Studio 2005 installation.

After numerous attempts on several computers, I finally realized what I was doing wrong. By adding the database instance name to the server name (# 5), it actually worked. Instead of selecting <server name> from the dropdown list, I entered <server name>\SQLExpress manually. That was obviously the problem.

SQL Server 2005 Express Edition is obviously installed as a named instance, since one has to provide the instance name in addition to the server name (even when there is only one instance running on the requested server).

|||

Hi

Have to tried

sp_configure 'remote admin connections',1

go

Reconfigure

go

Establish connection to the server

Hi,

I have a problem editing my SQL databases in Visual Studio 2005, i have searched the web for answers, but those were not clear enough to me, somthing about changing my settings for SQL server, but i didn't follow it all to well, the current error mesage I get when i click in the Server Explorer on my data connections is:

An error has occured 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 do have followed some tips, bit end to this error mesage every time. Bevore i followed that tips the error said:

(provider: TCP/IP, error ... i dont remember anymore...)

I have tried to delete SQL and Visual Studio but it didn't help, and reinstall it.

Please can somebody help me, i am realy fFrustrated about the fact i cant fix it!By default SQL Server Express does not have remote connections enabled. You can do this using the following instructions: http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx|||Yes, i have seen these instructions before, and i apply them again. But again without any succes. the error i now get is:

Connecting to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL: http://go.microsoft.com/fwlink/?LinkId=49251

I downloaded the file, open it. It recognizes the Named Instance as SQLExpress but then it said:

Name: Microsoft SQL Server 2005 Express Edition (SQLEXPRESS)

Allowed Action: Maintain (Action is only available from Add or Remove Programs)

Reason: Cannot maintain product, to maintain the product go to Add or Remove Programs

And the things i have in my Add or Remove Programs are:

Microsoft SQL Server 2005
Microsoft SQL Server 2005 Mobile
Microsoft SQL Server Native Client
Microsoft SQL Server Settup supporting files
Microsoft SQL Server VSS writer

What must i do?

|||

I encountered the same error message while trying to create a data connection from Visual Studio 2005 using the Server Explorer.

This is what I did:

# 1. Started Visual Studio 2005

# 2. Opened the Server Explorer (View | Server Explorer)

# 3. Right-clicked the Data Connections node

# 4. Selected Create New SQL Server Database... from the context menu

# 5. Selected my computer from the Server Name dropdown list

# 6. Selected authentication method (Use Windows Authentication)

# 7. Typed a name in the New Database Name field

# 8. Hit the OK button

That's when I received the following error message

An error has occured 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)

It made absolutely no sense. I wasn't trying to connect to a remote computer. I was simply trying to connect to the SQL Server 2005 Express Edition which was installed on my local computer during the Visual Studio 2005 installation.

After numerous attempts on several computers, I finally realized what I was doing wrong. By adding the database instance name to the server name (# 5), it actually worked. Instead of selecting <server name> from the dropdown list, I entered <server name>\SQLExpress manually. That was obviously the problem.

SQL Server 2005 Express Edition is obviously installed as a named instance, since one has to provide the instance name in addition to the server name (even when there is only one instance running on the requested server).

|||

Hi

Have to tried

sp_configure 'remote admin connections',1

go

Reconfigure

go