How to encrypt connection string without using ASP.net - asp.net

I created a windows library to do data reading from files and some custom filter, append, remove, update data towards my database on SQL Server. And my library requires app config which needs to put in connection string, because this library actually connects with more than 1 database.
If i were to deploy to my database server, i would need to do encryption to my connection string for security purpose. I have read a lot of discussion in stack overflow, but most of them are using RsaProtectedConfigurationProvider which requires my database server to have IIS server to do decryption. But the case is my database server don't add in the IIS on windows component as it will requires opening a new port which means open a new thread towards the server.
So my challenge right now is to do encryption of my app config without using any of ASP.net encryption tools. Is there any other way for me to do the encryption?

Related

Can I force an ASP.NET web app to pool or reuse connections without changing the code or connection string?

I have a web server with a legacy VB.NET/ASP.NET web app on it, and normal use of the app results in thousands of connections to the database server, all in series - open connection, execute really simple query that returns instantly, close connection, repeat. The ORM (custom-developed) is extremely inefficient and is the cause of these thousands of queries, but it's not something I can change in the app. The app also has the connection string hard-coded (though I can change the username and password from a config file).
The volume is so high that the SQL Server instance the app uses has to be on the same VM - even moving it to another VM on the same host can introduce timeouts or other user issues.
Without changing the code or the connection string itself, is there any way I can force the app to reuse connections or pool the connections, reducing the number it has to make? It's an ASP.NET 2.0 application, though it's running with SQL 2016 on a Windows 2016 Server, so maybe there's a new option in those somewhere.

How to "host" SQL Server when deploying an ASP.Net site on the web

I'm about to deploy an ASP.NET web application for testing in production. Essentially, this is just a table that is linked to a SQL Server table/view that is obviously dynamic when the data in the tables are updated.
I have a hosting plan with a site that I'll be pushing the files to, which includes a SQL Server database in the hosting plan. I also host a SQL Server instance on the network.
My question is, what is the standard way of dealing with SQL Server in this deployment? I think I have the options below, but as someone who has only ever developed applications offline, this is new to me, so please excuse my novice ignorance.
Have the application connect via IP address in the connection string to my SQL Server instance, as specifying the server name (SQLDEVSRV01 for example) won't be on the "network" when it's sitting in the site's FTP. Am I to assume my connection string will only work on the network, and once deployed to a website, will cease to function unless connecting via TCP/IP?
Host the server on the web in the same site host location. So upload the site files to my website host and setup the SQL server there. Would I be able to just specify the Server name (SQLDEVSRV01 for example) in the connection string there, as whilst it wouldn't work in development as it wouldn't be on the same network, it would then work once deployed on the web?
Embed a SQL Server instance within the app using localdB or something similar to hold the background data. If this is the case, can the data be accessed from the backend, either using SSMS or some other method?
Essentially, my aim here is to have the web app retrieve the data live from a view/table hosted in SQL server, where the backend data can be amended, manipulated and updated independently of the app, so the app can just pull the data when refreshed.
The standard way of doing this is to deploy your database to the hosting providers SQL Server instance and then connect your app to it using a connection string with their details. As it is normally a shared instance you do not have to normally worry about having the SQL instance machine patched etc.
Personally I would not be installing SQL Server myself unless I decided there was benefit to having an instance I wanted the control over nor would I be changing the structure or implementation of my application to suit a hosting providers setup.

Dynamic stored procedure in different SQL servers?

My client wants to change servers from the application, I mean enter new SQL servers name from application and search keywords in the SQL server database tables. I have Stored Producer which is working fine for one SQL server.
If client changes SQL server name in the application level then My connection string in the application will not work. Because database in the connection string that I used is available for one server.
How can I handle this situation? . Is there anyway sp that will be dynamic? P
Well in one server you could create a synonym that points at the other server. Assuming you have linked servers, on Server1:
CREATE SYNONYM dbo.ProcedureName FOR Server2_Linked.DatabaseName.dbo.ProcedureName;
Now when the app calls dbo.ProcedureName in Server1, unbeknownst to it, it is actually executing on Server2.
If this isn't what you're after I think you'll have to elaborate in your question a bit.

asp.net form submitting data to a mysql on Apache server

Basically to start with is it even possible to have a form that runs in asp.net and have it write data to a mysql database on a remote Apache web server? If so any pointers!? Not even sure really where to start researching it!
Yes and no...
form that runs in asp.net
Forms do not run "in" ASP.NET.
You can generate an HTML form using ASP.NET. You can submit form data to a webserver that uses ASP.NET to process the data.
write data to a mysql database
ASP.NET has database bindings that can talk with MySQL
mysql database on a remote
MySQL can listen on network interfaces so clients can connect over the network instead of using local sockets.
mysql database on a remote Apache web server
MySQL can't run on an Apache server. Apache is not an operating system.
MySQL can run on a server that is also running Apache, but with the above set up, Apache would be irrelevant.
Apache could be used to run a web service (e.g. written in Perl, Python or PHP) that connects to and queries a local MySQL server. ASP.NET could make HTTP requests to that webservice.
ASP.NET could be used to generate a form with an action that points to a URL that is handled by an Apache server.
Yes, you can write to a database anywhere in the world so long as you can:
Connect
Authenticate
Communicate (in a similar language)
You just need a connection to the database with valid credentials. You can talk to mySQL from .NET using the mySQL client.
In "theory" it's no different from a web server talking to a separate database server in the same building so long as the above three points are facilitated.

Multiple connections on a single .mdf database (ASP.net) SQL Server

I'm trying to place a .mdf database on a Computer A and access it simultaneously on Computer B but I'm having an error that says I cannot access the mdf file because it's being used by another process.
The setup is, the database is hosted on a Public folder in Computer A. I have Visual Studio running on both computers, and Computer B accesses the database on Computer A.
Computer A Connection path string:
C:\Users\Public\database.mdf
Computer B Connection path string:
\192.168.254.8\Public\database.mdf
Is there some sort of setting that I do not know of to enable multiple access on a db? Or this is not possible?
EDIT:
Let me rephrase my question, sorry.
There are two computers connected via a network, and I want to access one Visual Studio solution/project website. I wanted to do this as a demonstration, is it possible?
You should have an instance of SQL Server (even express) running on the host machine.
All requests from the clients should use the standard mechanisms for connecting to that server instance. In other words, they won't run their own copy of SQL Server, instead they will connect to the instance running on the host machine.
Simultaneous or direct access to Database files under any DBMS control either a very bad practice or simply impossible.
Use proper DBMS tools to access the data.
And yes - its possible to access Web site project for demo.
Install SQL Server on the host machine (the one that you want to keep your database on).
Then in Visual Studio, use the "Server Explorer" to locate the remote instance of the database. From there, you can utilize the remote instance of SQL Server in your connection string, thus allowing you to connect multiple computers to a single database.
Using two instances of SQL Server to connect to the single .mdf file is a very bad practice.
Instead of specifying the MDF file in your connection string (which, I believe, uses a form of User Instancing), you should use SQL Server Management Studio (SSMS) to attach the MDF. Then connect to SQL Server, rather than to the MDF.
You may need to move the MDF and LDF files to a place where the SQL Server identity can access them, rather than keeping them in your VS project.
Most projects keep scripts to create the DB in their VS project, but not the binary MDF itself.
When you deploy, the process is similar: use SSMS to attach the MDF on your server.
Yes, If 2 or More Computers are connected by networks like LAN You can access the Database Database1.mdf (say) from another SQL Server by entering its user name / Password /by Visual studio connection.
Disadvantages:
If more than 7~8 systems are accessing same Database same time System response slows down and Hangs up or may result error like connection pool exceeded or Device not responding..
In Big Companies they use Huge Multi-core & Multi-Processer based sever which will respond faster.
Overcome: while writing Applications Use Connection Open and Close Particularly while executing the SQL queries in other time it should be closed.
Best Programer uses Transaction instead of using normal methods. Transaction Makes Every User Access Database With valid and successful Execution of queries. These Queries (Transaction Queries) mainly executes on client machine and later updates the same over Main server when it got Time slot for it(synchronize).

Resources