sepehr_sepehr
پنج شنبه 12 شهریور 1388, 08:41 صبح
سلام
من به برنامم که یک windows application یک database1.mdf رو add کردم.و کد زیر رو برای ایجاد table در رویداد مربوط به کلید نوشتم:
private void button1_Click(object sender, EventArgs e)
{
string strsql = "create table tbl_" + textBox1.Text + "(tbl_id bigint identity(1,1) primary key)";
SqlConnection connection = new SqlConnection("Data Source=???????");
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = strsql;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
ولی نمیدونم به جای علامت سوال چی بنویسم؟هر چی که مینویسم برای کد connection.open(); این error رو میده!!!!
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)
البته به جای علامت سوال اینوهم نوشتم:
@"Data Source=.\SQLEXPRESS;Database=Database1.mdf"
ولی این خطا رو داد:
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
همچنین:
@"Server=YOUR-6BBD24890A\SQLEXPRESS;database=Database1.mdf;Integ rated Security=True;User Instance=True")
خطا:
Cannot open database "Database1.mdf" requested by the login. The login failed.
Login failed for user 'YOUR-6BBD24890A\
چه جوری باید connectionstring رو مقدار گذاری کنم؟؟؟
من به برنامم که یک windows application یک database1.mdf رو add کردم.و کد زیر رو برای ایجاد table در رویداد مربوط به کلید نوشتم:
private void button1_Click(object sender, EventArgs e)
{
string strsql = "create table tbl_" + textBox1.Text + "(tbl_id bigint identity(1,1) primary key)";
SqlConnection connection = new SqlConnection("Data Source=???????");
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandText = strsql;
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
ولی نمیدونم به جای علامت سوال چی بنویسم؟هر چی که مینویسم برای کد connection.open(); این error رو میده!!!!
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)
البته به جای علامت سوال اینوهم نوشتم:
@"Data Source=.\SQLEXPRESS;Database=Database1.mdf"
ولی این خطا رو داد:
Login failed for user ''. The user is not associated with a trusted SQL Server connection.
همچنین:
@"Server=YOUR-6BBD24890A\SQLEXPRESS;database=Database1.mdf;Integ rated Security=True;User Instance=True")
خطا:
Cannot open database "Database1.mdf" requested by the login. The login failed.
Login failed for user 'YOUR-6BBD24890A\
چه جوری باید connectionstring رو مقدار گذاری کنم؟؟؟