I want to automate some SQL queries to save time, so I tried using SQL Alchemy to connect to the server.
conn = create_engine("mssql+pymssql:/<user>:<pass>#<address>/<database>")
query = pd.read_sql_query(<query>)
This gave me an unknown connection error, so I looked around and found pymssql
db= pymssql.connect(host=address, user=user, password=pass, database=db, port=1433)
I am now getting this error:
OperationalError: (20009), d'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (address:1433)\nNet-Lib error during Unknown error (10060)\n'
Any help would be appreciated.
Related
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...
I have started getting an error on a page and am really struggling to work out the cause of this. I have searched on Stack Overflow for this same error message and found some people that got it also, but there solutions were very different to mine. This is the error message I'm getting:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '='.
/test-page.asp, line 97
This related to this line on that .asp page:
set rsMainContact=oConn.execute
("SELECT * FROM tbl_individual WHERE individual_id="&iMainContact)
Now the strange thing about this is that the page is actually bringing up the correct data, it's getting all the data it needs from that table. Which is why I don't understand why there's a problem.
Also, when I run the query using the "SELECT * FROM tbl_individual WHERE individual_id="&iMainContact" statement in MSSQL, replacing &iMainContact for an actual variable, it works absolutely fine.
Does anyone have any idea why this error might be occurring?
In case you want to know where the various variables come from then this is also some relevant code from the page:
SET rsOrganisationPendingOrganic=Server.CreateObject("ADODB.RecordSet")
rsOrganisationPendingOrganic.CursorType=3
rsOrganisationPendingOrganic.Open sSQL, oConn
iOrganisationPendingOrganicCount=rsOrganisationPendingOrganic.RecordCount
iMainContact=rsOrganisationPendingOrganic("organisation_maincontact")
if the following code is run BEFORE the error occurs, you most likely have no value for iMainContact:
SET rsOrganisationPendingOrganic=Server.CreateObject("ADODB.RecordSet")
rsOrganisationPendingOrganic.CursorType=3
rsOrganisationPendingOrganic.Open sSQL, oConn
iOrganisationPendingOrganicCount=rsOrganisationPendingOrganic.RecordCount
iMainContact=rsOrganisationPendingOrganic("organisation_maincontact")
you can prove this by writing out the sql to the screen before executing the failing sql:
Response.Write "SELECT * FROM tbl_individual WHERE individual_id=" & iMainContact
Response.End
I also agree 1000% with lad2025, use parameterized queries to guard against sql injection
I was trying to learn the new feature -- R in SQL Server 2016 and I was following this link as example.
I set up SQLRUserGroup as a new login and was able to run some R scripts, but the data_preprocess_score.sql gives me the following error message and it looked like related to connection.
Here is what I tried to call the sproc:
EXEC data_preprocess_score #testlength = 1, #id1value = 2, #id2value = 1,
#connectionString = 'SERVER=.;DATABASE=Test;Trusted_Connection=true;`'
Below is the error message:
Msg 39004, Level 16, State 20, Line 1
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 1, Line 1
An external script error occurred:
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Error in doTryCatch(return(expr), name, parentenv, handler) :
[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Calls: source ... tryCatch -> tryCatchList -> tryCatchOne -> doTryCatch -> .Call
In addition: Warning message:
In Ops.factor(tsvalues, value.threshold) : '>' not meaningful for factors
Error in ScaleR. Check the output for more information.
Error in eval(expr, envir, enclos) :
Error in ScaleR. Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted
STDOUT message(s) from external script:
Rows Read: 166, Total Rows Processed: 166Caught exception in file: CxAnalysis.cpp, line: 6488. ThreadID: 14112 Rethrowing.
[Microsoft][ODBC Driver Manager] Connection not open
ODBC Error in SQLDisconnect
Caught exception in file: CxAnalysis.cpp, line: 5682. ThreadID: 14112 Rethrowing.
Caught exception in file: CxAnalysis.cpp, line: 5249. ThreadID: 14112 Rethrowing.
Can someone help me with this error?
Thanks!
Add Driver=SQL Server to the front of your connection string. It wouldn't hurt to set Server=localhost too.
EXEC data_preprocess_score #testlength = 1, #id1value = 2, #id2value = 1,
#connectionString = 'Driver=SQL Server;SERVER=localhost;DATABASE=Test;Trusted_Connection=true;'
If you are able to run R scripts to get data, but get the following error with when writing data with rx functions like rxPredict/rxDataStep:
DBNETLIB; SQL Server does not exist or access denied
Then, you may be hitting an issue with loop back connections to SQL Server from R script. Please check the following configurations required for loop back connections:
Implied Authentication for Launchpad Accounts is enabled using instructions here
TCP/IP client protocol is enabled for the Server using instructions here
Specifically in your case, please check for the TCP/IP protocol configuration, since you mentioned the login for SQLRUserGroup was created.
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.
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.