MSSQL connection String: - sql-server

I'm trying to create scaledobject in keda and I'm referring the official keda documentation for this with MSSQL scaler.
While configuring connectionstring in this format "Server=example.database.windows.net;Port=1433;Database=AdventureWorks;Persist Security Info=False;User ID=user1;Password=Password#1;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" , Is the server to be configured is same as hostname?
Basically, whether the host parameter that we specify in connection parameters explicitly is the same as the Server parameter in ADO format: ?
Can someone please help me here? After deploying my scaled object in keda with MSSQL trigger(I'm considering server name is same as host instance and configured like that) , I'm getting ready and active status as unknown.. In logs I'm only seeing that it's trying to create a HPA and then nothing happens. I guess the operator is getting stuck here. Please guide me on how to proceed to establish connection with MSSQL

As per the docs you either have to specify the connection string OR host: keda.sh/docs/latest/scalers/mssql

Related

Google Data Studio MySql data source connection does not exist Error

Platform: Google Data Studio
Data Source: MySQL
Connection was working before,
meaning no issues with credentials.
All of a sudden, getting the below error:
All IPs have been whitelisted from the google data studio list of ips.
The only thing that comes to mind is a limitation of GDS to process data.
The data source table has around 200K+ rows.
Not sure what is the limitation for GDS with MySQL.
There's no indication anywhere.
Anyone out there can help to solve this or maybe provide some info would be appreciated.
Thanks
If you use a firewall, be sure to double check the Google ip adresses. They may have added new ips (in my case, the last one was missing).
Check them here !
After doing so, I had to change the Host name of the connection to the database for a url alias (www.yourserver.com <- url pointing on your server), and change it back to the IP to make it work.
Sounds like a the connector cannot establish a new connection.
Cloud SQL Connector:
At the time of writing this, the connector seems unable to establish a new connection once the existing one has timed out and modifying the JDBC url to include query parameters gives you an error when authenticating.
This is probably due to the connector appending it's own parameters.
(Seems to be a possible bug here when a connection no longer exists)
MySQL Connector (with IP Address):
This connector allows you to add query parameters to the JDBC url. Enable SSL and append useSSL=true to the url.
e.g.jdbc:mysql://<ip>/<database>?useSSL=true
This worked as expected and establishes new connections when required.
Example Source Setup
Suffering from this issue too, my experience is that using the MySQL connector instead of the Cloud SQL Connector provides better stability in combination with setting wait_timeout to a value above 12 hours.
This issue has been reported on the official Google Data Studio bug tracker. Please vote them up if you are also suffering from this !
🐛 130205306 MySQL connection does not exist Apr 9, 2019 04:36PM
🐛 118470083 Data source password not stored for MySQL sources. Oct 26, 2018 01:24PM

How to connect to simple database table?

I don't know much about databases - Sorry if the question seems silly.
I have sql server 2012 on my machine and i create simple database table.
I want to connect to this database table thru C# code.
So, I need to know my ConnectionString.
I don't understand the parameters of the ConnectionString.
I try to google it - but still didn't find any good explanation.
Anyone can please explain the connectionString fields ?
How to define the connectionString that i will be able to connect the local database ?
thanks
Your connection string should be as simple as like below
Data Source=.;Initial Catalog=DB_NAME;Integrated Security=True"
Where
Data Source=. means local database
Initial Catalog=DB_NAME means the database it will connect to
Integrated Security=True means it will use windows authentication (no user name and password needed; it will use logged in credential)
Take a look Here
(OR)
Search in Google with key term sqlconncectionstring which will fetch you many help.
EDIT:
You are getting exception cause Initial Catalog=DB_Name\Table_001. It should be Initial Catalog=DB_Name (only database name). Provide the table name in sql query to execute. Check some online tutorial to get more idea on the same.
You use . in data source only when you are connecting to local machine database and to the default SQL Server instance. Else if you are using different server and named SQL Server instance then your connection string should look like
using(SqlConnection sqlConnection = new SqlConnection())
{
sqlConnection.ConnectionString =
#"Data Source=Actual_server_name\actual_sqlserver_instance_name;
Initial Catalog=actual_database_name_Name;
Integrated Security=True;";
sqlConnection.Open();
}
In case you are using local machine but named SQL Server instance then use
Data Source=.\actual_sqlserver_instance_name;
Initial Catalog=Actual_Database_NAME;Integrated Security=True"
using System.Data.SqlClient;
Then create a SqlConnection and specifying the connection string.
SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;server=serverurl;" +
"Trusted_Connection=yes;" +
"database=database; " +
"connection timeout=30");
Note: line break in connection string is for formatting purposes only
SqlConnection.ConnectionString
The connection string is simply a compilation of options and values to specify how and what to connect to. Upon investigating the Visual Studio .NET help files I discovered that several fields had multiple names that worked the same, like Password and Pwd work interchangeably.
User ID
The User ID is used when you are using SQL Authentication. In my experience this is ignored when using a Trusted_Connection, or Windows Authentication. If the username is associated with a password Password or Pwd will be used.
"user id=userid;"
Password or Pwd
The password field is to be used with the User ID, it just wouldn't make sense to log in without a username, just a password. Both Password and Pwd are completely interchangeable.
"Password=validpassword;"-or-
"Pwd=validpassword;"
Data Source or Server or Address or Addr or Network Address
Upon looking in the MSDN documentation I found that there are several ways to specify the network address. The documentation mentions no differences between them and they appear to be interchangeable. The address is an valid network address, for brevity I am only using the localhost address in the examples.
"Data Source=localhost;"
-or-
"Server=localhost;"
-or-
"Address=localhost;"-or-"Addr=localhost;"
-or-"Network Address=localhost;"
Integrated Sercurity or Trusted_Connection
Integrated Security and Trusted_Connection are used to specify wheter the connnection is secure, such as Windows Authentication or SSPI. The recognized values are true, false, and sspi. According to the MSDN documentation sspi is equivalent to true. Note: I do not know how SSPI works, or affects the connection.
Connect Timeout or Connection Timeout
These specify the time, in seconds, to wait for the server to respond before generating an error. The default value is 15 (seconds).
"Connect Timeout=10;"-or-
"Connection Timeout=10;"
Initial Catalog or Database
Initial Catalog and Database are simply two ways of selecting the database associated with the connection.
"Inital Catalog=main;"
-or-
"Database=main;"

Connection String trouble

This isn't so much a programming issue, but i'm not sure where else to get this level of expertise.
In any case, the issue i'm having is getting a legacy application to run locally on my machine. it connects to a SQL server using this connection string
Provider=SQLOLEDB.1;Persist Security Info=False;User ID=UN;password=PW;Initial Catalog=DB;Data Source=IP
(where of course UN, PW, DB and IP are different, real, values)
I've changed it to this, to connect to a SQL Server Express instance on my local box:
Data Source=MY-PC-NAME\SQLEXPRESS;Initial Catalog=DB;Integrated Security=True
The app errors out with a generic cannot connect type error, which isn't helpful in the least bit.
Anyone have any advice? I don't have much more information on this blasted program ..
Try something like:
Provider=SQLNCLI10;Server=Server\SQLExpress;Database=myDataBase;Uid=myUsername; Pwd=myPassword;
VB6 used OLEDB syntax; your previous syntax was for .NET
This eventually worked Provider=SQLOLEDB.1;Persist Security Info=False;User ID=;password=;Initial Catalog=;Data Source=mypcname\SQLEXPRESS;Integrated Security=SSPI
I have no idea why. I needed to specify the integrated security.
Thanks for your help!

Connection Failed SQL Server

I have the following code snippet:
SqlConnection sr = new SqlConnection(this.strConnection);
sr.Open();
Where connection string is:
Data Source = localhost;Initial Catalog=UIB_IS;Persist Security info=True;User ID=USR;Password=PSW;
(I have removed the user name and password from above for purpose of this question - I have double checked the password has not expired and is still the same.)
Every time I try to open the connection I get a failed exception.
I have also tried using the Microsoft.SqlServer.Management.Smo.Server() object with a string connection as well as a ServerConnection object. With the server connection object using a string and SQLConnection object.
None seem to be working.
Within the connection string I have tried the syntax ServerName\SQLSERVERNAME, 127.0.0.1 as well as localhost as you can see above.
Previously this code has been working over the last 6 months using the 'ServerName\SQSERVERNAME' syntax in the connection string on a Microsoft.SqlServer.Management.Smo.Server() object.
This last week.....no longer works.
No System updates have been applied. The DB and SQL User exist with the appropriate permissions set as were before. SQL Server still has allow remote connections set to allow.
The server firewall is also off (Development machine)
I cannot understand why it would suddenly stop working?
Anyone have any ideas?
Thanks in advance.
Be sure that your Sql Server allow remote connections. You can check its status under Sql Server Surface Area Configuration --> Surface Area Configuration for Services and Connection.

How to Detect Trusted Connection in Crystal Reports using VB.NET?

I have some Crystal Reports connecting to a Sql Server db that I would like to detect whether the connection is trusted or whether I need to supply the log on info (reports are not supplied by me so I can't control the connect method). If I just blindly supply login credentials, it won't connect if it is a trusted connection.
The following does not work:
oRpt = oCR.OpenReport("C:\MyReport.rpt")
if oRpt.Database.Tables(1).ConnectionProperties.Item("Integrated Security") = True then
'trusted connection
else
'supply login credentials
end if
It gives the following error:
Operator '=' is not defined for type 'IConnectionProperty' and type 'Boolean'.
I cannot find how create a construct in vb.net for IConnectionProperty. I can't find any documents from Crystal that explain it.
I am using Crystal Reports XI - Developer
I think i found the answer. By using the property ConnectBufferString
Like this:
Console.WriteLine(oRpt.Database.Tables(1).ConnectBufferString.ToString)
It will give you a string like this
Provider=SQLOLEDB;;Data Source=MYPC\SQLEXPRESS;;Initial Catalog=sample_db;;User ID=;;Password=;;Integrated Security=-1;;Use DSN Default Properties=0;;Locale Identifier=1033;;Connect Timeout=15;;General Timeout=0;;OLE DB Services=-5;;Current Language=;;Initial File Name=;;Use Encryption for Data=0;;Replication server name connect option=;;Tag with column collation when possible=0
You just look for the following:
Integrated Security=-1 = Trusted Connection
Integrated Security=0 = Untrusted Connection
Hope this helps someone else since I wasted a few hours looking.

Resources