Here's my connection string
Server=XXX.XXX.XXX.XXX\SQLExpress;Database=inspection;User Id=sa;Password=xxx;
I'm getting an error that it couldn't connect, but when I use connection string like this
Server=.\SQLExpress;Database=inspection;User Id=sa;Password=xxx;
it connects successfully, I don't know whats problem (the Ip is correct)
If IP address is correct and you have firewall open and other stuff to be able to connect to this IP address, just try using it as is (i.e. without \SQLExpress part), so entServer=XXX.XXX.XXX.XXX;
You may not have enabled the TCP/IP protocol in the SQL Server Configuration Manager, which I believe needs to be enabled for connections that aren't localhost (i.e. .) to succeed.
Related
I have implemented FTP code with use of WinSCP .NET assembly and hosted it on an Azure AppService.
It works locally and on Azure.
But in very few random times, when hosted on Azure, it throws the following error:
Error transferring file 'D:\local\Temp\test_settings.txt'. Server sent passive reply with unroutable address 10.YYY.YYY.YYY, using host address instead. Copying files to remote side failed. Rejected data connection for transfer of "/test_settings.txt", IP addresses of control and data connection do not match
Since the IP starts with 10. does that mean that it's local in the FTP server's network?
Can I do something to improve the implementation?
Do you think that the solution will have a problem when used concurrently by multiple requests?
My code is a copy of the Simple C# example with the following settings:
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Ftp,
UserName = username,
Password = password,
GiveUpSecurityAndAcceptAnyTlsHostCertificate = true,
FtpSecure = FtpSecure.Explicit,
HostName = 'ftp.domain.com'
};
IP addresses of control and data connection do not match
That's a message from FileZilla FTP server. It's a security measure. It might indicate that external IP address of your app service instance changed mid transfer. Or of course, it might indicate that you connection was hijacked (that's what the server tries to detect).
It has nothing to do with WinSCP.
I do not know if the IP address of the Azure app service can be fixed somehow. If not, all you can do is to reconnect and retry the transfer. I believe you would have the same problem with any FTP client. Maybe with IPv6 connection, the problem would not happen. But I'm not sure, it's just a wild guess. Though you cannot force IPv6 with WinSCP (only by disabling IPv4 altogether, but I do not know if that's even possible with the app service).
Im using xammp as my platform for my database
Usually the defualt port of mysql is 3306 and it is working properly
But when I change the port like 4444 in my.ini I have an error message receive
cannot connect to any of the specified mysql hosts
By using this connection string
string connectString = "datasource=xxx.xx.xx.xxx;port=4444;username=root;password="";database=XXXXX;";
Well XAMPP might require a restart of MySQL server in order to update open port. But according to Connector strings, parameter "Port" might be ignored if Unix socket is used. So you can also check that.
Also, I know that have PHP in title, but I think it might be connected with your problem. Try this and say if it helped
I got error message when connecting my apps on client PC to the Database stored on Server PC(DESKTOP-F419755). I've tried using "localhost\SQLEXPRESS" and ".\SQLEXPRESS" but i got the same "Login Failed for user admin ..." message when trying to open connection. BUT, when i use "DESKTOP-F419755\SQLEXPRESS" for the Connection String it's works well on Client PC..
So how Client PC can connect to Server PC's Database without telling the Server PC Name.
My full Connection String was
"Data Source=localhost\SQLEXPRESS;Initial Catalog=data;User ID=admin;Password=adminPass"
note:
I can use either "localhost\SQLEXPRESS", ".\SQLEXPRESS", and "DESKTOP-F419755\SQLEXPRESS" on PC Server(Ofcourse).
So how Client PC can connect to Server PC's Database without telling
the Server PC Name
I am assuming you want to somehow mask the identity of the host in the configuration file for whatever reason. You can use the IP address directly in the connection string or add a host entry in the file: C:\Windows\System32\Drivers\etc\hosts
DESKTOP-F419755 serverhost
And use:
Data Source=serverhost\SQLEXPRESS;Initial Catalog=data;User
ID=admin;Password=adminPass
Is the configuration file exposed to users? What are you trying to accomplish exactly?
If your goal is to simply hide the machine name, this will accomplish albeit relatively half heatedly. If your primary concern is security you can pull the host name from somewhere inside the code and in the code generate the connection object therefore not needing the connection string stored in the config file.
This all depends on what you're trying to accomplish here, you could encrypt the information in the configuration file as well or store the host name somewhere else completely (registry, etc).
it's not possible to automate the connection string inside a client server location. however you can use another ways to store connection information to change without reinstalling the application.
Use a text file in a location with connection string. ensure that information are encrypted for security purposes.
Hope you got the answer.
I have SQL server 2000, and it have 2 other sql instances as well. Main sever has no issues, hereafter I am talking about those two instances,
They share,
Same machine
Same IP
Same Instance Name
Same Port
I too wonder how it has done.
Using query analyzer Once connect to,
MyServer\Invent (it connects to first instance)
MyServer\Invent,1433 (it connects to second instance)
(Yeah, it happens. I am 100% sure on that because I have separate DBs inside them)
Now it comes to problem,
With C# SqlConnection, I am unable to connect to first one, but can connect to second.
1. Data Source=MyServer\Invent;Persist Security Info=True;Initial Catalog=TEST;uid=admin;pwd=123
2. Data Source=MyServer\Invent,1433;Persist Security Info=True;Initial Catalog=TEST;uid=admin;pwd=123
Once I used 1st Connection String it hangs for a while and gets following error message...
"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: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"
Searched on net for this, many says installing such is possible. And one connection should use named pipes (tcp/445)
Any idea how to resolve this ?
Any possible Connection String format ?
Anyway of making Connection String for named pipes ?
I think your issue is that the one server is using a different port. So it's using TCP but a different port and you'll need to figure out what port is it using and then add that port to your connection string like you're doing with the other instance (1433).
you SQL Server configuration manager.
Navigate to the SQL Server Network Configuration Node and expand it.
Locate the instance in the children nodes
Now on the right hand side you'll see Protocols (Shared Memory, Named Pipes, TCP etc.)
Double Click on TCP.
In the dialog that pops up, switch to the IP Address tab.
Scroll all the way down to the "IP All" section
What does it say for TCP Port?
I think maybe your first instance is not actually listening on 1433, even though that is usually the default.
I believe it's possible to change the default port with the SQL Server Configuration utility. Check what the default port is, and assuming it's not 1433, try specifying it in the first connection string.
Here's some info about how to check which port your instance is listening on.
Edit: Ok, the first instance is listening on a named pipe. Maybe server=np:MyServer\Invent; will work, as per this page.
I am running a client/server application. I use a textbox to let the user type in the IP address and port. I try to connect to the server, using 127.0.0.1 and there is no problem. After that I tried using 192.168.2.102 (NAT ip address of this computer), and it fails. Any idea why?
the code I am using is: (this the the part that connects)
connect(string IPaddress, int port)
{
TcpCLient connection = new TcpClient();
connection.Connect(IPaddress, port);
}
I checked with debug, it DOES use the right IPaddress and port.
Firewall should allow it to connect. It's weird.
EDIT:
I think I know the problem. At the server side, I use
_listener = new TcpListener(IPAddress.Loopback, 8001);
And I think that's the reason why it only accepts connections from 127.0.0.1. But then, what should I use instead? I just want any connection from any IP with this port.
If you are specifying IPAddress.Loopback, then only connections to 127.0.0.1 will work. Replace it with IPAddress.Any to tell your server to listen on all interfaces.
First of all, the only circumstance I've ever seen return Connection was not possible because the destination computer actively rejected it is when there is actually nothing listening for connections at the specified address and port... or there is a firewall.
You may want to verify with a tracert that 192.168.2.102 actually points where you think it does. Another option is to use telnet from the command line to connect to the address and port if you really suspect there is a problem in your code (although I cannot see that apply here).
Addendum:
Is there any other application that can successfully make a connection to that specific IP address on that same machine?