بحثت كتير وجربت بس الكود ما اشتغل
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Exception e=new Exception();
try
{
SqlConnection myConnection;
// DataSet myDataSet;
SqlCommand myCommand;
SqlDataAdapter dataAdapter;
//string connectionString = "Server=localhost;DataBase=App_Data/my.mdf;Integrated Security=SSPI";
// string connectionString = "server=localhost;uid=;pwd=;database=App_Data/my";
//string connectionString = "provider=SQL; Initial Catalog=my Data Source=(local);";
string connectionString="Data Source=./SQLEXPRESS; AttachDbFilename=App_Data/my.mdf;";
myConnection = new SqlConnection(connectionString);
myConnection.Open();
// myDataSet = new DataSet();
string CommandText = "insert into test values(1,'abd')";
myCommand = new SqlCommand(CommandText, myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();
}
catch(Exception q){
Response.Write(q.Message);
}
}
}الخطأ
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)
انا عم استخدم vb 2005 وعم ابني القاعدة من داخل vb 2005