PDA

View Full Version : سوال: مشکل در کانکشن استرینگ , رفع ارور 26 - Error Locating Server/Instance Specified



Shakur_lotfy
چهارشنبه 11 بهمن 1391, 14:24 عصر
سلام
خواهش میکنم یکی کمک کنه
من 2 تا کانکشن استرینگ در web.config دارم
این سورسشه :
<connectionStrings>

<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\asp netdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />

<add name="papnewConnectionString" connectionString="Data Source=64.15.156.105,1433;Initial Catalog=pap;Persist Security Info=True;User ID=papuser;Password=Sh121212" providerName="System.Data.SqlClient" />

<add name="MyConn" connectionString="Data Source=64.15.156.105;Initial Catalog=pap;Persist Security Info=True;Password=Sh121212;User ID=papuser" providerName="System.Data.SqlClient" />

</connectionStrings>

2 تا صفحه دیگه هم دارم مه تو صقحه اول sql datasource و listview استفاده کردم و توی صفحه دوم میخوام یوزر پسورد بگیرم و بعد برم به یه صفحه دیگه . برای هر دو صفحه ارور میداد ولی وقتی ای پی دیتا بیسم رو بهش دادم ارور برطرف شد و listview کار کرد (کانکشن استرینگ اول) ولی در مورد کانکشن دوم هر کاری میکنم ارتباط با پایگاه دادهم وصل نمیشه و ارور زیر رو میده :

A network-related or instance-specific error occurred while establishing a connection to SQL Server
The server was not found or was not accessible
(provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

این سورس فایل login.aspx هست :

string constring = ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString;
SqlConnection conlogin = new SqlConnection(constring);
SqlCommand command = new SqlCommand();
command.Connection = conlogin;
command.CommandText = string.Format("select Id from tblmanager where Username = '" + txtuser.Text + "' and Pass = '" + txtpass.Text + "' ");
command.CommandType = System.Data.CommandType.Text;
command.Connection.Open();
object obj = command.ExecuteScalar();
command.Connection.Close();

توی ویژوال استودیو همه چیز به خوبی کار میکنه
خواهش میکنم کمکم کنییییییییییدددددددددد :گریه: :گریه: :گریه: