简体   繁体   中英

connection string

I have a problem with my connection string. When using web service from server i see this error:

Format of the initialization string does not conform to specification starting at index 114

But in local host i don't have any problem. and my connection string is:

name="DB_nodeEntities1"        
connectionString="metadata=res://*/Models.Node.csdl|res://*/Models.Node.ssdl|res://*/Models.Node.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=xx.xxx.xxx.xx,1433;
initial catalog=my db name;
integrated security=True;
MultipleActiveResultSets=True;
App=EntityFramework"
User Id=my id;
Password=my pass" 
providerName="System.Data.EntityClient"

i think it's related to server security policy. for example some SQL server doesn't allows you to remote access and you should connect locally. maybe what happened to you is something like this. in such case your hosting service and database engine should be on the same server also contact your server administrator.

let me know when exception occurred, is it happens when you run your website in debug mode on your computer? if yes, I recommend you test it on server.

also what's your server type (Linux&Windows) and which language you use to implementation. but if you use windows server for both hosting and Database engine and implement in .Net framework i have some suggestion based on your error. first of all check this link . secondly check your connection directly in SQL Server management studio, if you can't connect, so it's clearly shows you don't have permissions and first theory confirmed.

Have you tired creating a connection string via a UDL file and simply copying and pasting that into your code?

  1. Open up file explorer, and anywhere you fancy, create a new text file but change the extension to .udl instead of .txt.
  2. Double click to open that new .udl file and you will see the below;
  3. The provider tab lets you choose what data source type you want to connect to, go ahead and select Microsoft OLE DB Provider for SQL Server.
  4. On the connection tab, you can click on the drop down for the server name, and it will show a list of SQL server's it has found that you can connect to. In the past I have seen this not work so well, so you can manually type in your server name. You can then specify the login type, which will either be Windows Authentication (use the currently logged in user details to log into SQL Server) or provide the user name and password.
  5. You will notice on the option for specific user name and password that there is 2 tick boxes. If the login you want to use does not need a password, make sure you check the blank password box as simply leaving the password textbox blank will not work. The allow saving password will save the password value as a raw text value in the connection string (ie, easily readable). You can encrypt connection strings in your application config file which I will explain later, I always tick this box but I will leave that up to you.
  6. You are now ready to select the database you want to connect to on the server, clicking on the dropdown arrow on the database on the server dropdown will display all the database's you are able to connect to with the login details you just provided.
  7. With all that done, click on Test Connection and it should work. If you get any failure then message box will offer some help but it will most likely be the wrong login details or you simply cannot access the database.
  8. Now close this dialog by clicking OK, any other way of closing this dialog will lose your work. In file explorer, right click on your .udl file, select open with and choose NotePad (or any other text editor).
  9. Now in notepad, you have your connection string! You just want to copy the parts that start after Provider=SQLOLEDB.1;.

I've got a blog post here which explains how to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM