Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Why sometime this message appear???
Israel
Oct 13 2015 9:56 AM
282
Reply
Hi,
I have somethink I need to understand. Why this message appear sometime when I run my program. It doesnt appear allways. But sometime. When Then how can I fix it to evitate because when I comment my connection its works for a while (later its buggs). Even I leave my connection in order or open/close (its works but anytime later its buggs). Thes error message:
The connection was not closed. The connection's current state is open.
public Entrada()
{
InitializeComponent();
}
OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Visa\App_Data\finance.mdb;Persist Security Info=False");
OleDbCommand comm;
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Visa\App_Data\finance.mdb;Persist Security Info=False";
conn.Open();
// the error message point here
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from Lancamento where data_recepcao ='" + dtEntrada.Text + "'";
var param1 = new OleDbParameter("@data_recepcao", OleDbType.VarChar);
param1.Value = dtEntrada.Text;
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
dgvLancamento.DataSource = dt;
conn.Close();
// the error message point here
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
wpf and database
i need a code