reza1078
شنبه 20 تیر 1388, 01:41 صبح
دوستان یک مشکلی دارم :یک textbox دارم و حالا می خوام اطلاعاتش رو به دیتابیس ارسال کنم (همه چیزش و درست انجام دادم از نظر خودم)
detailview , sqldatasource رو انجام دادم
و کد c# زیر رو براش نوشتم:
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;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
SqlConnection objConnection = new SqlConnection("Data Source=.;AttachDbFilename=|DataDirectory|\\test1.m df;Integrated Security=True;User Instance=True");
SqlCommand objCommand = new SqlCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "INSERT INTO tabel " + "(fname, lname) " + "VALUES(@fname, @lname)";
objCommand.Parameters.AddWithValue("@fname", txtAuId.Text);
objConnection.Open();
objCommand.ExecuteNonQuery();
objConnection.Close();
}
}
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
{
}
}
یک text box بیشتر نداریم و اطلاعات هم مشخصه اما در بین راه eror زیر رو می ده اگه امکانش هست سریعتر کمک کنید:
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)
detailview , sqldatasource رو انجام دادم
و کد c# زیر رو براش نوشتم:
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;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
{
SqlConnection objConnection = new SqlConnection("Data Source=.;AttachDbFilename=|DataDirectory|\\test1.m df;Integrated Security=True;User Instance=True");
SqlCommand objCommand = new SqlCommand();
objCommand.Connection = objConnection;
objCommand.CommandText = "INSERT INTO tabel " + "(fname, lname) " + "VALUES(@fname, @lname)";
objCommand.Parameters.AddWithValue("@fname", txtAuId.Text);
objConnection.Open();
objCommand.ExecuteNonQuery();
objConnection.Close();
}
}
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
{
}
}
یک text box بیشتر نداریم و اطلاعات هم مشخصه اما در بین راه eror زیر رو می ده اگه امکانش هست سریعتر کمک کنید:
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)