ado .net , sql server connection

G

Guest

i have a sql server and asp .net application on the same box. The sql server instance name is cdcrs204\NETSDK. tThe following connect string works fine in the application on the server

Me.SqlConnection1.ConnectionString = "data source=52.99.20.25\NetSDK;initial catalog=sac;persist secu" &
"rity info=True;user id=sa;packet size=4096;Network Library =dbmssocn

But this gives following exception when I run application locally from my machine. I can see the instance 52.99.20.25\NetSDK from Enterprise manager

Server Error in '/SAC' Application
-------------------------------------------------------------------------------

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied

Source Error:

Line 214: cmdIOC.Connection.ConnectionString = SqlConnection1.ConnectionStrin
Line 215
Line 216: cmdIOC.Connection.Open(
Line 217
Line 218: cmdIOC.CommandType = CommandType.Tex


Source File: C:\Inetpub\wwwroot\SAC\WhatIf.aspx.vb Line: 216

Stack Trace:

[SqlException: SQL Server does not exist or access denied.
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +47
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +37
System.Data.SqlClient.SqlConnection.Open() +38

[TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) +
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) +42
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +2
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o, MethodBase method, ParameterInfo[] Parameters, Object[] args, Type objType, IReflect objIReflect) +24
Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) +42
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) +2
sac.WhatIf.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\SAC\WhatIf.aspx.vb:21
System.Web.UI.Control.OnLoad(EventArgs e) +6
System.Web.UI.Control.LoadRecursive() +3
System.Web.UI.Page.ProcessRequestMain() +73



-------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Any help is appreciated

thanks
 
W

William Ryan eMVP

Rach:

Please tell me this is a joke. If not, please tell me that IP address isn't
real. If it is, go kill SA right now.

If you've changed it in the post, my apologies. Let me know and I'll walk
you through it.

rach said:
i have a sql server and asp .net application on the same box. The sql
server instance name is cdcrs204\NETSDK. tThe following connect string works
fine in the application on the server.
Me.SqlConnection1.ConnectionString = "data
source=52.99.20.25\NetSDK;initial catalog=sac;persist secu" & _
"rity info=True;user id=sa;packet size=4096;Network Library =dbmssocn"

But this gives following exception when I run application locally from my
machine. I can see the instance 52.99.20.25\NetSDK from Enterprise manager.
Server Error in '/SAC' Application.
-------------------------------------------------------------------------- ------

SQL Server does not exist or access denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.

Source Error:


Line 214: cmdIOC.Connection.ConnectionString = SqlConnection1.ConnectionString
Line 215:
Line 216: cmdIOC.Connection.Open()
Line 217:
Line 218: cmdIOC.CommandType = CommandType.Text


Source File: C:\Inetpub\wwwroot\SAC\WhatIf.aspx.vb Line: 216

Stack Trace:


[SqlException: SQL Server does not exist or access denied.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +472
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnec
tionString options, Boolean& isInTransaction) +372
System.Data.SqlClient.SqlConnection.Open() +384

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) +0
System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo
culture, Boolean verifyAccess) +422
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +23
Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o,
MethodBase method, ParameterInfo[] Parameters, Object[] args, Type objType,
IReflect objIReflect) +241Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack, Boolean IgnoreReturn) +429
Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o,
Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack) +23
 
C

Carl Prothman [MVP]

rach said:
i have a sql server and asp .net application on the same box.
Me.SqlConnection1.ConnectionString = "data
source=52.99.20.25\NetSDK;initial catalog=sac;persist secu" &
_ "rity info=True;user id=sa;packet size=4096;Network Library
=dbmssocn"

Rach,
If SQL Server is on the same box as ASP.NET, then try the following
connection string:
"data source=(local)\NetSDK;initial catalog=sac;
user id=SqlServerUserOtherThanSA;password=myPassword"
http://www.able-consulting.com/dotnet/adonet/Data_Providers.htm#SQLClientManagedProvider

You should not be using "sa" for database connection! Create a
new SQL Server user, which only has permissions to execute
stored procedures, and no permissions to the tables. Then use
stored procedures for all database access. Also make sure to
NOT give the sql server user account access to "master",
which sql server 2000 does by default (arg!).
 
G

Guest

IP address exists and the following connect string works fine from the application on the production server which is also on 52.99.20.25

One thing should be remembered though , the following connect string works fine on the server:
Me.SqlConnection1.ConnectionString = "data source=52.99.20.25\NETSDK;initial catalog=sac;persist secu" &
"rity info=True;user id=sa;packet size=4096;Network Library =dbmssocn

I just doesn't work from my machine. I 'm trying to connect to sql server 52.99.20.25\NETSDK from my local box. I can see the database instance and read /write to the tables from the Enterprise manager

Thank

thanks
 
W

William Ryan eMVP

Rach:

First, do yourself a favor and don't use SA and no password. Second don't
post this type of info in a public forum - too many troublemakers out
there....

Is your connection from EM done with SA and blank password or is that an
omission? Also, do you have 1433 open
Rach said:
IP address exists and the following connect string works fine from the
application on the production server which is also on 52.99.20.25.
One thing should be remembered though , the following connect string works fine on the server:
Me.SqlConnection1.ConnectionString = "data
source=52.99.20.25\NETSDK;initial catalog=sac;persist secu" & _
"rity info=True;user id=sa;packet size=4096;Network Library =dbmssocn"

I just doesn't work from my machine. I 'm trying to connect to sql server
52.99.20.25\NETSDK from my local box. I can see the database instance and
read /write to the tables from the Enterprise manager.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top