PDA

View Full Version : همه چی درسته به دیتا بیس هم کانکت اما باز هم خطا!!



fsima
چهارشنبه 03 بهمن 1386, 01:39 صبح
به cn.open(); ایراد میگیره همه چی درست دیتابیس ام کانکت
کد ام اینه
protected void Button1_Click(object sender, EventArgs e)
{
string sqlstr = "insert into tbl(Name,Family) values ('" + TextBox1.Text + "','" + TextBox2.Text + "')";
ConnectionStringSettings Settings;
Settings = System.Configuration.ConfigurationManager.Connecti onStrings["connStr"];
string connectionString = Settings.ConnectionString;
SqlConnection cn = new SqlConnection(connectionString);
cn.Open();
using(SqlCommand cmd = new SqlCommand(sqlstr, cn))
cmd.ExecuteNonQuery();
cn.Close();

}

و توی web.confing هم کد زیر رو نوشته ام

<configuration>
<appSettings/>
<connectionStrings>

<add name="connStr" connectionString="Data Source=hamidiya-02f2ed;Initial Catalog=Camera;Integrated Security=True"
providerName="System.Data.SqlClient" />

</connectionStrings>
<system.web>
خطا ی زیر رو میده
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

el_abdollahi
چهارشنبه 03 بهمن 1386, 10:24 صبح
من وقتی این خطا رو میگیرم که sql server در حالت stop هست .

eyes_shut_number1
چهارشنبه 03 بهمن 1386, 14:54 عصر
من فکر میکنم یورز aspnet رو توی sqlserver فعالنکرده باشی یعنی رول بهش نداده باشی!