Click here to Skip to main content
15,843,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<configuration>
  <appsettings>
    <add key="ohpc_connectionstring" value="SERVER=192.168.15.130;User Id=root;pwd=password;database=ohpc_new1;Persist Security Info=True" />
  </appsettings>
</configuration>



I have declare this code in app.config file but It does not work properly and show error message. So how can I modify the code to access mysql database from our remote server. For mysql database userid =root but we have not set any password for database.

[edit]Code block and HTML encode added to make code fragment visible! - OriginalGriff[/edit]
Posted
Updated 28-Aug-12 23:34pm
v2
Comments
OriginalGriff 29-Aug-12 4:36am    
When you post a question (or answer) please check the preview - if you don't encode HTML tag characters then the client browser will "swallow" them, hiding all your code fragment! I have fixed it for you here - have a look with the "Improve question" widget and you will see what I mean.
Sarrrva 29-Aug-12 4:42am    
http://www.codeproject.com/Questions/433687/sql-server-connectity-over-the-internet

Hi Dear,

try this code in app.config file

XML
<?xml version="1.0"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
  <connectionStrings>
    <add name="SqlServerConnectionstring" connectionString="Password=password;Connection Timeout=0;Persist Security Info=False;User ID=userid;Initial Catalog=Database Name;Data Source=servername;" />
   </connectionStrings>
</configuration>


in C# form page use the following code to acces the SqlServerConnectionstring

SQL
ConfigurationManager.ConnectionStrings["SqlServerConnectionstring"].ToString();
 
Share this answer
 
v2
XML
<configuration>
    <appSettings>
        <add key ="Connstr" value="SERVER=192.168.15.130\SQLExpress;
database=databaseName;uid=UserId;pwd=Password"></add>
    </appSettings>
</configuration>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900