When I am assign connectionString via code as: SqlConnection conn = MyConnection.ConnectionStr(); Then it's working perfectly. Or hardcore string in aspx page is also working.
But when I am assign string to SQlDataSource on Page_Load then it's giving me an error as
Format of the initialization string does not conform to specification starting at index 0.
But if connectionString is placed in separate class file then this method would give the following error.
I have a web project and made a MyConnection.cs in DAL folder under App_Folder. Class file is as below:
namespace SLI.App_Code.DAL
{
public class MyConnection
{
public static SqlConnection ConnectionStr()
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=10.148.7.54;Initial Catalog=xxx;Persist Security Info=True;User ID=xxxx;Password=xxxxxx; Max Pool size = 500; Pooling = True;";
return conn;
}
}
}
I need to assign MyConnection class string to SQlDataSource. How should I do this ?