Question Error while using environment variables

KishoreKesava

New member
Joined
Jul 25, 2024
Messages
2
Programming Experience
5-10
Error while using environment variables .
Format of the initialization string does not conform to specification starting at index 0
 
I suggest that you change the initialisation string to conform to the specification.

Here's an idea: how about you show us the code and, if relevant, the data that generates this error message? If you want help with code that doesn't work properly, it should be obvious that showing us that code is a prerequisite. You don't need any programming experience to know that people need to know what you're doing to know what you're doing wrong.
 
I suggest that you change the initialisation string to conform to the specification.

Here's an idea: how about you show us the code and, if relevant, the data that generates this error message? If you want help with code that doesn't work properly, it should be obvious that showing us that code is a prerequisite. You don't need any programming experience to know that people need to know what you're doing to know what you're doing wrong.
C#:
public static string connectionString = SQLUtil.getConnectionString();
public static List <DataObjects.StrInt1> GetCategories(string a, string b)
{
         List<DataObjects.StrInt1> dataList = new List<DataObjects.StrInt1>();
       string SqlCommand = $@"select catgeoryId from tbl_category Where lower(id)=@a and name=@b";
       try
          {
               using(DbCommand objCmd = DBFactory.Instance.SqlUtil.Database.GetSqlStringCommand(SqlCommand))
            {
                      DBFactory.Instance.SqlUtil.Database.AddInParameter(objCmd,"@id",DbType.AnsiString,a);
                                           DBFactory.Instance.SqlUtil.Database.AddInParameter(objCmd,"@name",DbType.AnsiString,b);   
                  using(IDataReader reader=DBFactory.Instance.SqlUtil.Database.ExecuteReader(objCmd))
                   {
                         while(reader.Read())
                         {
                                  DataObjects.Str1Int1 dataObj = new DataObects.Str1Int1();
                                  dataObj.ParamInt1 = reader[0].GetInt32();
                                  dataObj.ParamInt1 = reader[1].ToString();
                          }
                   }            
             }
                    return dataList;
          }
          catch(Exception e)
          {
               throw e;
          }
}
 
Last edited by a moderator:
I'm not seeing anything in that code that uses environment variables. Are you sure you are showing us the correct code?

Perhaps it is the code in SQLUtil.Database.ExecuteReader() that you need to show us?
 
Given the error message, the issue is likely a faulty database connection string but you haven't provided any code that creates or uses a connection string, so what you have provided is all but useless. The exception would have told you where it was thrown but you seem to have ignored that. Wherever the database connection is opened is where the exception will be being thrown but it's the connection string and wherever that comes from that is the root of the issue.
 
Back
Top Bottom