ADO.NET SqlClient connection string - Data Source syntax - ado.net

Is there any official write-up what forms can Data Source field take in sql server connection string? I'm aware of following forms:
SERVER
SERVER\Instance
tcp:SERVER,port
nb:SERVER
nb:SERVER\Instance
are there more forms?
EDIT: The essence of this exercise is not to construct a connection string. I am trying to parse existing connection string, and I want to know all the forms it could take. I appreciate everybody who pointed me to www.connectionstrings.com, and this site is useful enough, but it clearly does not have all the information. For example, it will not specify that it is possible to use construct like "Data Source=tcp:SERVER,10000" to specify that TCP must be used for this datasource on port 10000.

check this website for all connection string questions: http://www.connectionstrings.com

This website has more than you could possibly ever want to know about connection strings for SQL Server and many other databases:
Connection strings for SQL Server 2005

Related

How to avoid Mongo DB NoSQL blind (sleep) injection

While scanning my Application for vulnerability, I have got one high risk error i.e.
Blind MongoDB NoSQL Injection
I have checked what exactly request is sent to database by tool which performed scanning and found while Requesting GET call it had added below line to GET request.
{"$where":"sleep(181000);return 1;"}
Scan received a "Time Out" response, which indicates that the injected "Sleep" command succeeded.
I need help to fix this vulnerability. Can anyone help me out here? I just wanted to understand what I need to add in my code to perform this check before connecting to database?
Thanks,
Anshu
Similar to SQL injection, or any other type of Code Injection, don't copy untrusted content into a string that will be executed as a MongoDB query.
You apparently have some code in your app that naively accepts user input or some other content and runs it as a MongoDB query.
Sorry, it's hard to give a more specific answer, because you haven't shown that code, or described what you intended it to do.
But generally, in every place where you use external content, you have to imagine how it could be misused if the content doesn't contain the format you assume it does.
You must instead validate the content, so it can only be in the format you intend, or else reject the content if it's not in a valid format.

Config file for Connection string in SSIS

I am new to SSIS, I have created variables for connection string (Both source and destination). While generating the Config file, which property I need to select. Could you please help me with this?
It's not necessary to create variables for a connection string.
There are a few things you will need to provide to us to give you an exact answer.
The type of database you are connecting to.
What type of authentication you use to connect to it.
If you take the below image when setting up a connection manager for an OLE DB you simply need to provide the server name. Then which type of authentication it is.
If the connection is successful you should be able to select a database you wish to connect to. You can also test the connect to make sure the connection is working successfully.
Let me know if you have any other issues.
Thanks
Gav

View Postgres connection string

Is there a way I can view the connection string used by the client to connect to my Postgres instance?
Problem:
I am connecting to Postgres via jasper and I am setting prepareThreshold=0 in the connection string to disable prepared statements. I see that it's not being honoured for some reason. So I would like to confirm that jasper is actually passing the setting in the connection string correctly.
You can ask the database server only for information it has.
prepareThreshold is a setting of the JDBC driver, and the database has no knowledge about it.
You can cast the java.sql.Connection to an org.postgresql.PGConnection and use the getPrepareThreshold() method to get the desired information.

Connect to a DBIx::Class database without repeating the connection details?

DBIx::Class::Manual::Intro
suggests connecting to the database as follows
my $schema = MyApp::Schema->connect(...)
explicitly providing connection details such as the password.
I want to connect to the same database from multiple different scripts, and it would be unwise to code the same connection parameters into each of the programs separately.
What is the "official" way to create a connection method with fixed connection details?
I realize that I can write something like this
package MyApp::Schema;
use base qw/DBIx::Class::Schema/;
sub my_connect {
$_[0]::SUPER->connect(...);
}
1;
Is this approach recommended?
I realize that providing different connection details may be useful for testing scripts, but in reality we do not yet use testing scripts, so this is currently irrelevant for our team.
Put your connection details in a config file, create a utility to return the connection and read the config details like you showed, or as a factory type function. Make the config dependant on the environment and you'll have testing capabilities for free.

Is there a parameter I can provide to a Postgres connection string to "name" a client?

We have a postgres database which a lot of scripts connect to. Crucially, there is not a username per-script; there are a (small) number of usernames which are shared around the place.
When doing troubleshooting or performance optimising, it would be very useful to know which server SQL process corresponds (or corresponded, past-tense) to which script.
I am thinking of something like:
host=db-server dbname=whatever clientID=script1.py
I suspect the answer is "no", but my google-fu is weak.
You can explore using the "application_name" parameter. Depending on what your code is doing you can log it.