PAYAM202
دوشنبه 31 شهریور 1393, 15:30 عصر
ببخشید دوباره مزاحمت شدم یه صفحه ای طراحی کردم روی سرور آپلود شده قراره اطلاعات فرم توی بانک اکسس 2007 ذخیره بشه. روی سیستم خودم مشکلی ندارم اما نمی دونم چرا روی سرور این پیغام رو میده:
The connection was not closed. The connection's current state is open.
سرچ کردم اما متوجه نمیشم باید چی کار کنم.asp.net,C#
کد اتصال:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
namespace WebApplication1
{
public partial class contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection cnon = new OleDbConnection();
cnon.ConnectionString =@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\hostingspaces\kazel.com\kazel.com\wwwroo t\dbkaz.accdb;Persist Security Info=False;";
if (cnon.State == System.Data.ConnectionState.Closed)
{
cnon.Open();
}
OleDbCommand command = new OleDbCommand();
command.CommandText = "INSERT INTO tb (companyname,fname,lname,email,address,country,cit y,postcode,phone,engine,comment) VALUES ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + DropDownList2.SelectedValue + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + DropDownList1.SelectedValue + "','" + TextBox11.Text + "')";
command.Connection = cnon;
command.ExecuteNonQuery();
conn.Close();
}
}
}
The connection was not closed. The connection's current state is open.
سرچ کردم اما متوجه نمیشم باید چی کار کنم.asp.net,C#
کد اتصال:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
namespace WebApplication1
{
public partial class contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
OleDbConnection cnon = new OleDbConnection();
cnon.ConnectionString =@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\hostingspaces\kazel.com\kazel.com\wwwroo t\dbkaz.accdb;Persist Security Info=False;";
if (cnon.State == System.Data.ConnectionState.Closed)
{
cnon.Open();
}
OleDbCommand command = new OleDbCommand();
command.CommandText = "INSERT INTO tb (companyname,fname,lname,email,address,country,cit y,postcode,phone,engine,comment) VALUES ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + DropDownList2.SelectedValue + "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" + DropDownList1.SelectedValue + "','" + TextBox11.Text + "')";
command.Connection = cnon;
command.ExecuteNonQuery();
conn.Close();
}
}
}