I made an application to insert and view data from service-based database (cDatabase.MDF).
I have 3 PC, I want to run the application in all PC to insert the data in the same database
I'm using SQL Server 2008 Express.
Here are the steps I followed (I'm not sure if they are correct )
open SQL Server Configuration Manager to turn on the TCP/IP from Client Protocol and Protocols for SQL Server Express
Set local Static IP for the PC. 192.168.1.10 , 192.168.1.20 , 192.168.1.30
Set the three PC on one WorkGroup
Turn off the firewall on all PCs
Change connection string to
Data Source=192.168.1.10\SQLEXPRESS;Initial Catalog=cDatabase;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True
I shared my application folder on the network from PC1 ( 192.168.1.10 )
when I open the applicaton from the shared folder (in all PCs) I get this error
Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
How to fix this error? And thanks
Set the Integrated Security to False in your Connection String.
Related
I have created a simple login application using the C#.net. I have some basic sql database(I use SSMS). There is name, email and password. I want my application to be usable from more devices (so I can't use localdb). Everything works fine on my pc but when I move to another, where is not installed ssms it shows error 26 - Error Locating Server/Instance Specified. I don't know how exactly to run my C# application without SQL Server Management Studio installed on client machine
I have researched for a weeks so I enable tcp/ip (from sql server manager), also add new inbound rules for tcp(1433) and udp(1434) ports in windows firewall. After that I allow remote connection and add sql server in windows firewall. Also I've tried to install SSMS on client machine but nothing
here are my conncetion strings
this one I tried to solve my problem
Data Source=xxxxxxxxxxxx;Initial Catalog=xxxxxxxxxxx;Integrated Security=SSPI
the other one is my main connection string
Data Source=xxxxxxxxxxxxxxxxxxxxxxx;Initial Catalog=xxxxxxxxxxxxxx;Integrated
Integrated Security = True
The application works fine on my computer, I've installed Visual Studio 2017 and SQL Server Management studio, but when I move to another computer it doesn't work.
Thanks to everyone in advance!!
SSMS is just a Database Management Tool, the actual Database would by SQLExpress or similar. So on your remote host you need to install the latter and set it up correctly in you application to use to appropiate connectionstring to it.
Schema compare your tables from VS and your ready to go.
https://www.microsoft.com/en-us/sql-server/sql-server-editions-express
https://www.mssqltips.com/sqlservertip/5528/installing-sql-server-2017-express/
You dont need to install sql or sql managemment studio in pc where you running your application, but just as your error said "Error Locating Server/Instance Specified", the server where you want to connect, is not accesible, thats means you should open your ports in pc where your sql server is hosted, and also, put your public ip following with that port in your server name in conectionstring, like Data Source=yourserver_IP:8076; tip: make sure your app pc and server pc are in same network.
The reason it works on the same machine is most likely is is that when you go through another machine the connection has to go through a firewall that is blocking access to SQL Server. The default port that SQL Server uses is 1433 and unless you change it on the host machine when you connect from another machine that is the port that is use to connect and you don't have to specify the port. When you connect on the same machine that SQL Server is installed the firewall does not prevent you from connecting. Port 1433 is used for the default instance (The first installed instance on the machine).
I have created a Sql Server Managment Studio database, that is on Google Cloud virtual machine. Now i have C# winform app on a remote pc, and i am trying to retrive a table from that database. Virtual machine is Windows Server 2012R2 Datacenter. SSMS on virtual machine is 2014 and SQL Server 2014.
I get error in C# saying: The server was not found or was not accesible. Error 40- could not open a connection to SQL Server.
My connection string in C# is:
String strConnection=#"Data Source="Virtual machine IP"; Initial Catalog ="db
name"; User
ID="username";Password="password";";
Also i think i could connect to database on virtual machine, using my SSMS on my remote pc. I tried using IP address of virtual machine computer(ipconfig) and used username and password that i created in a VM SSMS. Also tried windows authetication with that ip. But everything with no succes. Error: The server was not found or was not accesible.
-I have allowed remote connections in SSMS.
-Have set SSMS login mode to mixed.
-Have set firewall exceptions on virtual machine for inbound rules, port TCP 1433, port UDP 1434, application sqlservr.exe, application sqlbrowser.exe
-On virtual machine in SQL Server Configuration Manager i have enabled TCP/IP, Named Pipes, Shared Memory
-SQL Server and SQL Browser are running on virtual machine.
If anyone has any ideas what to try next, i would be delightful.
On cloud , you get the URL(connection) from the host page , not just IP address
this work perfect
example for AWS cloud ms sql :
add name='YOURNAMEConnectionString'
connectionString=" Data Source=YOUR_ACCOUNT_LINK.rds.amazonaws.com ;
Initial Catalog=;User ID=;Password=;Connect Timeout=80000 "
providerName="System.Data.SqlClient"
In PC1 I created a C# application wins forms which uses local SQL server database then I deployed my application to .exe file using Visual studio. Then I installed the exe file into same PC (PC1) and I works fine and can connect to SQL database using the following connection string:
SqlConnection con = new SqlConnection("Data Source=local; Initial Catalog=mydb; Integrated Security=True");
The problem is: when I went to another PC (PC2) I installed SQL server and I manually attached the same database (mydb) and then installed my application but it gives me the following error:
However, when I change the name of PC2 same as PC1 the application can connect and it works well.It means if I want to install my application in different PC then I have to name that PC same name as the original PC which I created my C# in (PC1).
why is this error happening? I mean why do I have to set other PCs to have the same name as the original PC (PC1). Please help me how to fix this eror. Thank you
You don't have to have the same name on different PCs to have a C# program connected to a SQL server. One thing I would like to point out, maybe you are aware maybe you are not. If you install the database on EACH machine they programs won't share the data (again, this might sound silly but just in case).
To the error itself, if you installed SQL Server on machine PC2 go to Services and double check that the SQL Server INSTANCE is the same as the one you set up on your connection string. You don't have to even have the same database name it could be totally different on each machine, the important thing there is to have the correct connection string (you should have the connection string as a configuration that you can easily change from a .conf file.
Just double check on PC2 that the server is working as expected (check services and Event Viewer for any errors that might popup) you can also try instead of local 127.0.0.1
You need to activate Sql Server and Windows authentication in your sql server and change your connection string from integrated security to user/password authentication.
Data Source needs to be changed either to IP or to the name of the server
I am working on a Windows Forms application written in C#, and using Entity Framework 6 to connect to a SQL Server database, currently on the same local computer -- which I will be separating on another computer on production of course.
Now, would I need to alter anything before building the release? Or would the program find the database automatically when connected on the same local network?
You can connect to remote SQL by changing connection string from App.Config.
You can use server name : IP\SqlExpress, 5012.
Here IP is your public IP where DB is setup and 5012 is random port.
I have a WinForms program I am creating for a friend of mine that uses a SQL Server Express database. Locally, I can connect to my SQL Server Express fine and when I deploy the app to his computer, it works also. I'm having difficulty connecting to his SQL Server Express instance from my machine though (I'm trying to run the program in debug mode in vs2012 but connected to his database). The program uses Entity Framework in case that matters (I don't think it does).
We've setup his firewall to allow my IP address to access his computer and his SQL Server... so I can log in via remote desktop and I can also connect using SSMS from my pc and see all the databases.... but why can't I connect using vs2012? I'm thinking it has something to do with the connection string but haven't found a working solution yet.
Here's what I have tried:
Got these from ConnectionStrings.com:
Server=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
DataSource=100.100.100.100\SQLExpress;Database=TestDB;User Id=UserID;Password=myPassword;
Obviously the IP address has changed for the purposes of this post.
Any ideas?
You've used the connection string attribute:
DataSource
There is no such thing, and I suspect it was just a typo (it pays to use cut and paste instead of transcribing). There is actually a space in that attribute, so it should be:
Data Source
Here is a list of things you need to check on the other computer:
Is TCP/IP protocol enabled? Go to SQL Server Configuration Manager -> SQL Server Network Configuration -> Protocols for {instance}
What IP addresses are enabled for listening in configuration manager? Go to TCP/IP properties -> IP Addresses tab
SQL Server browser started
Firewall set properly – you want to enable TCP and UDP traffic on port 1433
Server allows remote connections? In SSMS open properties for that instance and check Connections tab.