Home > Net > System. NullReferenceException: "the object reference not set to an instance of an object."
System. NullReferenceException: "the object reference not set to an instance of an object."
Time:09-25
C # program problem, the great god help String strCon=ConfigurationManager. ConnectionStrings [r]. "SQLString" ConnectionString;
Below is the specific code
CodePudding user response:
Check whether the XML defines the connection string,
String conn=ConfigurationManager. ConnectionStrings [" connSql "]. The ConnectionString;
<? The XML version="1.0" encoding="utf-8"?> connSql "connectionString=" Server=.; The Database=test; Uid=sa; The PWD=sasa; MultipleActiveResultSets=true "providerName=" System. The Data. SqlClient/& gt; "" & lt;/connectionStrings> & lt;/configuration>
CodePudding user response:
String conn=ConfigurationManager. ConnectionStrings [" connSql "]. The ConnectionString;
<? The XML version="1.0" encoding="utf-8"?> connSql "connectionString=" Server=.; The Database=test; Uid=sa; The PWD=sasa; MultipleActiveResultSets=true "providerName=" System. The Data. SqlClient/& gt; ""
CodePudding user response:
I am a rookie a, can you explain it
CodePudding user response:
Means you can put the configuration file & lt; Configuration> The content of the node to
CodePudding user response:
The web. Config or app. Look at the SQLString config