Showing posts with label valid. Show all posts
Showing posts with label valid. Show all posts

Friday, February 24, 2012

Connection string problem.

+ ex {"The name \"CHARACTER\" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."} System.Exception {System.Data.SqlClient.SqlException}
+ dr {System.Data.DataRow} System.Data.DataRow
dr[1] "CHARACTER" object {string}
dr[2] "NAME" object {string}
dr[3] "14/09/2006 12:00:00 AM" object {string}
dr[4] "" object {string}
dr[5] "1" object {string}
dr[6] "1" object {string}
dr[7] "1" object {string}
dr[8] "" object {string}
dr[9] "" object {string}
dr[10] "80" object {string}
dr[11] "False" object {string}
dr[12] "" object {string}
dr[13] "" object {string}
dr[14] "" object {string}
dr[15] "" object {string}
dr[16] "True" object {string}
dr[17] "False" object {string}
dr[0] "1" object {string}
edtProjectName.Text.Trim() This expression causes side effects and will not be evaluated string
+ ex {"The name \"CHARACTER\" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."} System.Exception {System.Data.SqlClient.SqlException}

public ProjectToDB(string _projectDBName)

{

projectDBName = "RG_ProjectData_"+_projectDBName;

conn = new SqlConnection("Initial Catalog=??;Data Source=10.1.1.99;user id=sa;password=Password123");

}

?this needs to be placed by projectDBNamestring projectDBName = "pubs";
SqlConnection objconn = new SqlConnection("Initial Catalog=" + projectDBName + @.";Data Source=192.168.1.1;user id=sa;password=passwd123");

Quote:

Originally Posted by macupryk

+ ex {"The name \"CHARACTER\" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."} System.Exception {System.Data.SqlClient.SqlException}
+ dr {System.Data.DataRow} System.Data.DataRow
dr[1] "CHARACTER" object {string}
dr[2] "NAME" object {string}
dr[3] "14/09/2006 12:00:00 AM" object {string}
dr[4] "" object {string}
dr[5] "1" object {string}
dr[6] "1" object {string}
dr[7] "1" object {string}
dr[8] "" object {string}
dr[9] "" object {string}
dr[10] "80" object {string}
dr[11] "False" object {string}
dr[12] "" object {string}
dr[13] "" object {string}
dr[14] "" object {string}
dr[15] "" object {string}
dr[16] "True" object {string}
dr[17] "False" object {string}
dr[0] "1" object {string}
edtProjectName.Text.Trim() This expression causes side effects and will not be evaluated string
+ ex {"The name \"CHARACTER\" is not permitted in this context. Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted."} System.Exception {System.Data.SqlClient.SqlException}

public ProjectToDB(string _projectDBName)

{

projectDBName = "RG_ProjectData_"+_projectDBName;

conn = new SqlConnection("Initial Catalog=??;Data Source=10.1.1.99;user id=sa;password=Password123");

}

?this needs to be placed by projectDBName

Connection string not valid !

I've build a website with asp.net and on my local machine it run very we. but when I store my website on a server, I have a error : ...error: 25 - Connection String not valid...

This is my connection string on my local machine : "add name="csIyp" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|iyapason.mdf;User Instance=true" providerName="System.Data.SqlClient" "

And the connection string on my webserver : "add name="csIyp" connectionString="data source= .\MSSQLSERVER;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|iyapason.mdf;User Instance=true" providerName="System.Data.SqlClient" "

So, what can I do to solve this probleme.

Thanks !

Does your web server have an actual SQL Server Express database engine installed, or SQL Server 2005 of some kind (as in, not Express). If the later, attaching DB on the fly like that string does might not work.|||There is a SQL Server 2005 engine installed on my webserver and i think that the instance name is "MSSQLSERVER". so can I have a sample connection string?|||

Hi siebobby,

Base on my understanding, we will not install SQL Server Express on the web server. So I think MSSQLSERVER is not an Express Edition. If my supposition is incorrect, please feel free to point out.

AttachDBFilename is used to specify the database to attach to the user instance. And User instances only work in the Express Edition of SQL Server 2005. So you must change the connect string for new SQL Server, the string may likes below:

connectionString="Data Source=.\MSSQLSERVER;Initial Catalog=iyapason;Integrated Security=True"

Be sure attaching iyapason.mdf in the MSSQLSERVER first.