Debug and Cannot Open Connection to SQL - sql

When debugging in SQL, I get the following exception :-
System.Data.SqlClient.SqlException: 'A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)'
When I then set next statement and run the statement again, it works. It also works when I'm running the application standalone as a compiled application. Anyone know why this causes an error only when in debug.
The connection is to a remote database sited off-site, not to the local database.
Data Source=xx.xx.xx.xx;Initial Catalog=TheDatabase;User ID=MasterUser;Password=AsIfIMGoingToPostThat
Your help, appreciated.
This is my function to connect...
Public Sub New(ByVal strConnect As String)
Try
dbConnect = New System.Data.SqlClient.SqlConnection(strConnect)
dbConnect.Open()
objParams = New List(Of SqlClient.SqlParameter)
m_bIsConnected = True
Catch exc As Exception
m_bIsConnected = False
Finally
End Try

It looks like your local connection doesn't default to named pipes but your compiled version will try (or is allowed to use TCP/IP). The error shows that it may be expecting named pipes.
Try putting this "np:" in the Data Source in your connection string:
Data Source=np:xx.xx.xx.xx; ...

To get it to connect first time, it looks like I need to add "Network Library=DBMSSOCN;" to connect in debug. t.b.h., Have no idea why...

Related

ODBC Connection in Project.params | SSIS

i need help establing ODBC Connection in project params in my SSIS.
Not sure what I'm doing wrong or I missed some steps.
My Source connection fails when im using my ODBC connection in project params.
But when I use package level ODBC Connection, it is working.
Error is:
[C8PF 1] Error: The AcquireConnection method call to the connection
manager FBEQ failed with error code 0xC0014009. There may be error
messages posted before this with more information on why the
AcquireConnection method call failed.
Highlighted in yellow are set to project.params
my odbc configuration:
I think that the main problem is in the ODBC Connectionstring provided in the parameter, click on the local package connection manager and press F4 to show the properties Tab. Go to Connectionstring property and check the syntax used. Try to use the same syntax in the parameter value.
Another thing to try, is providing an empty password in the connection string:
DSN=myDsn;Uid=myUsername;Pwd=;
connectionstrings - System DSN

failed to connect to a database in B1if

sometimes i have this error when i try to connect to my database in B1if :
vBIU.errhdlg='' exceptionmsg='com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception:
com.sap.b1i.bizprocessor.BizProcException: BPE001 Nested exception:
com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception:
com.sap.b1i.xcellerator.XcelleratorException: XCE001 Nested exception: java.lang.RuntimeException: Connect to
Business One failed. (-119) Database server type not supported -b1Server=SRV-B1-HYPPROD,
company=SBO_HYPFR_PROD, licenseServer=HYP-B1-LIC:30000, dbType=7, dbUser=sa, userName=B1i-' msglogexcl='false'
handover2CentralSrv='' MessageLog='true' msglogdbop='insert'>
the question is how to fix that ?
The Error happens when B1i don't get a connection to the DB. That should not be a problem because B1i repeats the process after a minuten and then the connection should be there.
We fixed this by Installing the 64 Bit version of B1DIAPI.x64. Not sure why that worked.
Note you need to update the SLD links for your database and SBO-COMMON - the jcoPath will likely be different - replace the "Program Files (x86)" with just "Program Files".

Clean and reset table in mvc 4 Web application

I am wanting to delete all data from a table and reset the id column to 1. I want to do this in my controller, but i want to know the best way to do that. I have tried the SQLConnection/SQLCommand route, but have been unable to connect to the database successfully to do that. Is there a way like running a db.Clean function or something like that?
Updated
Here is how far it gets in the code:
string connectionString = "Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\\Webs\\MvcFFL\\MvcFFL\\App_Data\\Players.mdf;Integrated Security=True";
string queryString = "Truncate table Players;";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlCommand command = new SqlCommand(queryString, connection);
connection.Open(); <- Fails here opening the connection
}
Then when it hits the connection.Open() here is the error:
An exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll but was not handled in user code Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
What can i do instead of this method?
You have an unescaped \in (LocalDB)\v11.0
You can change it to (LocalDB)\\v11.0, or else change the whole connection string to
#"Data Source=(LocalDB)\v11.0;AttachDbFilename=c:\Webs\MvcFFL\MvcFFL\App_Data\Players.mdf;Integrated Security=True" (notice the # and the lack of \\)

SQL Anywhere connection error: The driver doesn't support the version of ODBC behavior that the application requested

I'm trying to connect to a SQL Anywhere 5 database (I know it's olllld!) with a .NET 3.5 app in WinXP and it works fine from a stand alone console app. But when I run the exact code in a plugin ,running off a separate AppDomain, (the only difference I can tell between the two) with the following code, I get the errors further below.
BTW Both are executed as the SAME user.
using (OdbcConnection connection =
new OdbcConnection(strConnect))
{
OdbcCommand command = new OdbcCommand(query, connection);
command.CommandType = CommandType.Text;
DataTable posRecordsTable = new DataTable();
connection.Open();
OdbcException Exception returns the following errors:
Index #0
Message: [Sybase][ODBC Driver]Unable to connect to database server: database engine not running
Index #1
Message: [Sybase][ODBC Driver]Invalid connection string attribute
Index #2
Message: [Sybase][ODBC Driver]Invalid connection string attribute
Index #3
Message: [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
Does the driver on your AppDomain have the same configuration as your stand alone box? I think checking the similarity of the environments will help you. Usually such errors are resolved by looking at the config files from where the driver reads its information. Dont know much about SQL Anywhere, but in general, I've come across such issues and I fixed them by altering the connection information or the configuration file.

Connecting to SQL Server 2005 using classic ASP

I have installed both IIS and SQL Server 2005 on my laptop.
Both work individualy, however when I try to connect to an DB from an ASP page I keep getting the following error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database "DB1" requested by the login. The login failed.
/testFiles/Connection/Connection.inc, line 5
Line 5 says:
con.open "DSN=DB1"
Can anybody tell me what the problem is?
Thanks
Below is a sample, but I think you are having a problem with credentials. Go through the configuration of the DSN and make sure it connects.
set conn = server.createobject("ADODB.Connection")
set rsuser= server.createobject("ADODB.Recordset")
conn.open CONNECTIONSTRING
sql="SELECT * FROM Table"
rsuser.Open sql,conn,1,2
rsuser.close
set rsuser = nothing
conn.close
set conn = nothing
Your Connection string "DSN=DB1" is lacking credentials at the minimum (which is why the login failed)
www.connectionstrings.com is a very useful website that will help you construct your connection string. You can select the DB you are working with and provide the details (server,DB, username,password,dsn.....) and it will help give you back the connection string.