I have recently accepted a project from a company. I have to display data from there database. I got the files on my local computer and created a program to their liking but when I replace the path and datasource in the connection string an error occurs. The error reads that
FirebirdSql.Data.FirebirdClient.FbException (0x80004005): Your user name and password are not defined. Ask your database administrator to set up a Firebird login.
So afterwards I copied the database on their local pc that has access to this remote server. I changed the connection string to where the DB is located on the local pc. Used the same username and password and then the connection worked.
A littile more about their server. The server is setup for a program which connects to their DB and runs on the server. The company's employees works from this program on their local computers. I do not have direct access to this server since the server does not connect to the internet at all. I used teamviewer to test my program.
So here is my connection string both the remote and local
The connection string that follow is for their network
connectionString = "Server=192.168.1.10;User=sysdba;Password=masterkey;Charser=NONE;Database=\\192.168.1.10\\DB\\DB.fdb";
The connection string that follow is for the local pc at the company I tested on using teamviewer.
connectionString = "Server=localhost;User=sysdba;Password=masterkey;Charser=NONE;Database=C:\DB\DB.fdb";
NOTE: I am not sure if the program the employees use might interfere with the one I created.
This might be too late but as a reference for the others, this is how I connect to the Firebird Database that is place in the other server.
This is the sample connection string if Firebird is installed in the same server:
connectionString =
"Server=localhost;User=sampleusername;Password=samplepassword;Charser=NONE;Database=C:\DB\DB.fdb";
So if it is installed to different server, just get the IP of the the server and location of the FDB file from the server. For example, server IP is 192.168.1.123, the following will be the connection string:
connectionString =
"Server=192.168.1.123;User=sysdba;Password=masterkey;Charser=NONE;Database=192.168.1.123:C:\DB\DB.fdb";
Just supplied the server IP with colon in front and the followed by the full path of the database. And for the server, just set the same IP Address.
I hope that this can help the others. Thanks.
Verify with isql if you can connect to the database, see this article
Verify your code with the example on the Firebird site
Check the aliases.conf
Use a GUI tool like IBExper to manage users and databases
Anyway is better, for security reason, to use another user instead of sysdba.
Passwords to firebird are local to the server (in its security2.fdb). If you copy the database to your local machine (this indicates lax security BTW), and access it through a local Firebird server, it will use the security2.fdb of that local machine. The sysdba password you have is valid on your local machine (it is the Firebird default).
Clearly the password on the server is different. You need to find out what the password is or ask their DBA to give you a specific account.
As to your comment on the other answer that the database is in a shared folder: do not do this. Firebird databases should be accessed by one (or more) server processes on the same machine. Clients etc should connect through the server, and not open a shared file. Trying to open a shared database file is blocked by default, but if done could potentially corrupt the database; also having a database on a shared folder is a bad security practice.
Related
I am using C#, .NET Framework 4.5.2 and SQL Server 2014 Express edition (v12.0.2000). My requirement is to access this software from another PC means client system. Software is working fine in server PC not accessible in client PC.
Working until now
I followed the following two Microsoft official documents to make the database accessible on another PC:
https://learn.microsoft.com/en-us/sql/relational-databases/lesson-1-connecting-to-the-database-engine?view=sql-server-ver15
https://learn.microsoft.com/en-us/sql/relational-databases/lesson-2-connecting-from-another-computer?view=sql-server-ver15
To connect two PCs I followed this tutorial.
Result so far
I am able to access software in the network directory. I can run the .exe file of software on the client's PC. I can access the SQL Server in Microsoft SQL Server Management Studio on the client PC.
Can't do so far
The only thing that I can't do till now is my software on the client's PC is not able to access the database. It shows an error
Login failed for user
Connection string
I thought it should be a connection string error. I tried three different connection strings, let me write all here:
Data Source=.\\SQLEXPRESS;Database=dbposrpc;trusted_connection=true;
Data Source=.\\SQLEXPRESS;Initial Catalog=dbposrpc;User ID=sa;Password=12345678;
Data Source=tcp:DESKTOP-0DCQGE3,49172;Initial Catalog=dbposrpc;User ID=sa;Password=12345678;
SQLEXPRESS is the SQL Server instance name, DESKTOP-0DCQGE3 is the server PC name, 49172 is the TCP port that I selected.
For accessing a software from remote PC(Client's PC) you need to add inbound rules in Windows Defender Firewall with Advanced Security for this port the software is hosted on, then you also need to forward the port from your server PC.
The issue is resolved! All the steps I followed are perfect. You can say that if you want to connect to the client's PC using an ethernet connection. Follow the steps in question step by step. Focus on the connection string. Use the connection string of number 3. Let me write it again for clarification.
Data Source=tcp:DESKTOP-0DCQGE3,49172;Initial Catalog=dbposrpc;User ID=sa;Password=12345678;
Here SQLEXPRESS is the SQL Server instance name, DESKTOP-0DCQGE3 is the server PC name, 49172 is the TCP port that I selected as static.
How I resolved the issue?
I just cleared the solution, restarted the project again and everything worked fine for me.
I've just start working on an ASP.NET Web Application in Visual Studio 2015 and SQL Server 2014. Somewhere, I need to connect to my local database and I use this:
ConnStr = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=my_db;Integrated Security=True";
It works fine when I run the application through VS in my browser. I can access the db and do whatever I want to do. But, when I publish my application in IIS Web Server, and then I open it in browser, it still works OK until I have to access the db. At that moment it throws SqlException:
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. .
Maybe it is a server name problem and I should use an IP and a Port instead of that name, but I'm not sure because I don't have experience on this.
You are correct: You should use server name and/or IP in your connection string.
Using something like "local" or "localhost" means that your code is not portable. Another option would be to store your connection strings in two separate config files - one for your local copy (for development and troubleshooting) and one for your server (for portability). I have two config files in my solutions:
Web.config
WebServer.config
Then, when I deploy to the server, I just delete Web.config and rename WebServer.config to Web.config. It's totally portable and you'll never have connection string troubles again!
Also noteworthy: you're not including credentials in your connection string, which means that you're using windows authentication when connecting to SQL server. When debugging through visual studio, the application will run as you - and if you have the needed permissions, it will work. However, when running in IIS, it won't be running as you (at least, it SHOULDN'T be) - so you could run into issues there, as well.
EDIT
This link might be useful for you: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx
Your connection string should look like this:
Data Source=192.168.1.10,1433;Initial Catalog=YourDatabaseName;User ID=SqlUserName;Password=SqlPassword;Connection Timeout=60; Max Pool Size=3000;
(you can set max pool size and connection timeout to whatever you want - or omit them entirely.
Also, regarding your windows issues - you need to make sure that the windows account IIS is using has permissions to traverse your network and reach your SQL Server instance. That said, I suggest that you use a SQL account instead of windows authentication.
Since you are using integrated security in connection string you will have to modify the Identity of App pool under which your application is running.
The Identity will be your windows username and password.
To change the username and password you need to go the advance settings of the app pool and process model you can see identity where you can add your windows credentials
Hope this helps
There are two problems in you connection string:
"Integrated Security" means you are using the native windows system for authentication. Similar to opening SSMS on the database using your Windows password. IIS is now trying to connect to the database, and connection string is telling to use the process that IIS is running under.
You can create a non-windows user in SQL Server and put the credentials into the connection string. Or you can grant the IIS user DB privileges. Or you can a lot different things here, but theses are the easiest to get you moving.
THe second problem in the connection string is the data source. Is there SQL Server on you local machine? If so that's why it's not working. Try to run your app in VS but against the remote SQL Server. That should be your next step.
The problem was that I thought that SQL Server was installed automatically with VS or at least with SQL Server Management Studio. BUT NO. So, as far as I understand, till know I have not worked with a real SQL Server. When I checked SQL Server Configuration Manager there were nothing running at SQL Server Services and so I realized that I was missing something.
Then, I installed SQL Server Express and build my db there. Now it is working fine even when I publish it. The connection string is
Data Source=.\\SQLEXPRESS;Initial Catalog=my_db;User ID=username;Password=pass
It can also be:
Data Source=localhost\\SQLEXPRESS;Initial Catalog=my_db;User ID=username;Password=pass
I need some opinions and ideas on how to choose and use sql connection string? i do search fom sqlconnectionstring's website, but i tried for few types couldn't work with my network system. can pros out there help me please?
My condition is like below:
I got 1 computer for hosting and i installed sql2008 express server(microsoft sql management studio), and login as window authentication. (ip: 192.168.1.101)
With my created database was with out any security login id and password. (.MDF)
I got another computers work as client to connect and access the hosting computer which hosting the sql server. there ip had set to static (192.168.1.102, 192.168.1.103, 192.168.1.104)
i had tested this connection string but i failed to get connect
Data Source=192.168.1.101,1433;Network Library=DBMSSOCN;
Initial Catalog=myDataBase
I did configure the firewall to allow the 1433 ports which is my sqlserver current using port. Checked sqlserver tcp:enabled, via:enabled, Namepipe:enabled, shareMemory:enabled. Setting of allowed computer remote-able.
So far these are what i configured, but still unable to connect, can anybody guide me?
Maybe because you're using a windows authentication. If you're connecting to SQL server using another computer, the login of that computer should be:
A part of a domain where the server is (i.e. [domain]\myusername).
It should be added to the SQL Server's Security\Login. Go to management studio, then in the object explorer under the server, go to the folder Security\Login. You should see a list of users under login. Your user (other computer's login) should be there.
Now, if you're not part of a domain, you should use a SQL server authentication. I haven't tried using windows authentication in two computers which is not part of a domain.
I'm currently developing a web application using asp.net c#. I got a server where I today was
going to publish my website and its database. Its a server that runs Windows Server 2008 R2.
But I have one issue:
My website doesn't seem to get access to the database. If I run the website from another computer on my local network I can access the server's database, BUT I can't when I run the website from the same server where the database is. This is really weird. I hope someone can help.
I just get an error that says, it can't access the database.
The most weird of all is that I'm using the same connection string on both computers, but it still doesn't work. Are there maybe some sort of settings in Windows Server 2008?
Here is my connection string:
<add name="ConnectionString"
connectionString="Data Source=AXELS;Initial Catalog=Sailor;Persist Security Info=True;User ID=sa;Password=saab123"
providerName="System.Data.SqlClient" />
Since the connection works on one machine and not on another, I'd guess you have an issue with a firewall or similar - but it will be hard to tell until we see the actual error message. Until then, there are a few things you might want to do:
If it appears as if the connection has to time out before you get the error, it indicates a connectivity problem. Do you have a firewall between the two servers? Does the database server have a firewall that explicitly lets your machine (or internal) machines get through, but hasn't been setup to let the webserver get through? You have to make sure that port 1433 is open on the server.
Are there other sites on the webserver that can connect to the database?
If you have console access to the server, try to set up an ODBC from the server to the database - usually in Control Panel -> Data Sources (ODBC). If you set up a connection with the same DB Server, username and password and test the connection, you might get some pointers to what is wrong.
If the above doesn't provide you with an answer, I'd try to go through the steps described here:
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
And if that fails, take a look at this - which is apparently only valid when you get SQL Network Interfaces, error: 26
http://blogs.msdn.com/b/sql_protocols/archive/2007/05/13/sql-network-interfaces-error-26-error-locating-server-instance-specified.aspx
This is probably a permission problem.
You need to show us your connection string so we can see how exactly you try to connect to your database.
For example, if you are using Windows authentication, maybe your app runs under different accounts on both machines - and the account on the other computers has permission to access the database, but the account on the database server has not.
Have you checked the if the protocols you are using are enabled on the SQL Server e.g.
C:\Windows\System32\cliconfg.exe -- 64 bit version
C:\Windows\SysWOW64\cliconfg.exe -- 32 bit version
or check SQL Server Configuration Manager 'SQL Server Native Client *' tabs.
This is only applicable if you do not use Windows Authentication, else read the post about priviliges from Christian Specht - in this case I agree.
The fact that you can connect from another PC on the network means that all you database settings, user accounts and permissions are probably set up correct.
It seems there might be a issue with the way the server resolves localhost, as it will try to resolve the Data Source to localhost because AXELS = localhost on that machine.
Have a look at your hosts file and see if there's any funny pointers except for the default.
Located in C:\Windows\System32\drivers\etc
There should be an entry: 127.0.0.1 localhost
I've just finished my c# application with sql database built in 2008 r2 version
I wanted to share this database over LAN and my connection string is :
ConnectionString = #"Data Source=192.168.0.1,1433\SQLEXPRESS;user id=Rula; password=marojo;AttachDbFilename=\\192.168.0.1\Release\WEPA.mdf;Connection Timeout=30;Integrated Security=SSPI;user instance=true";
where 192.168.0.1 is the IP of the computer hosting the sqlexpress instance
when I connect to database locally from the hosting computer I get no errors, but when I try to connect to the database from the shared application I get the following error:
User doesn't have permission to perform this action.
while I mapped the GUEST user to my database on the hosting machine since I knew that if a computer try to connect to database remotly, it connect as guest.
notice: I have my application and database shared over network in the same folder, and again locally everything is ok
Please what can I do to solve this problem ????
thanks in advance =-)
If the 2 machines are not on the same domain this will fail. You might want to use sql logins
The guest account would not be used in an trusted connection. The integrated connection uses the user account attached to the process using the connection string.
http://forums.asp.net/t/822604.aspx/1
If you wanted to use integrated security, the web server would need to be configured to digest logins and then you would need to grant access to all (potential) authenticated users access to the database. This is typically not done due to the unnecessary complexity you are adding to the process. Just use sql links like Ali stated and be done with it.
Okay, I see a couple things that are wrong in your connection string.
Namely, you have defined a user id and password... then you go on to set the Integrated Security flag. These are mutually exclusive. Either it connects as the same user that the app is executing under (most likely the app pool user account) OR it connects as the user defined in your connection string.
The reason you see a difference between 7 and XP is simply that one is defaulting to using the user id / password, the other is defaulting to using integrated security.
I suggest that you visit http://www.connectionstrings.com/ in order to build a proper connection string.
Update:
Other things I see. First, AttachDbFilename can only work with integrated security. Obviously that isn't a possibility, so you need to get rid of that parameter and configure sqlexpress directly on the server to target that database file.
Second, User Instance is for desktop deployments.. not servers. Get rid of it as well because it's going to be a huge memory hog.
Third, read this: http://msdn.microsoft.com/en-us/library/ms247257(v=VS.100).aspx
There are quite a few reasons this could be happening:
SQL Browser service not turned on
Connection string using a trusted connection and you are not set up as that user (check what user your code is using by getting User from the current context)
You do not have the same protocols set up on the client (less likely)
Since it is a permissions issue, you will most likely have to set up your windows domain account in the database to use it. If that is not an option for the application users, then you may desire to move to a sql account rather than windows accounts.
problem solved !!
there was just attaching problem when the database is attached to sql server management studio it's attached as an old name or related to the computer it's copied from
Thank you everyone for your effort : )