IF i run my VB.NET Application.
IT shows"Unhandled exception has occured.Connection was not closed.The Connection's current state is open".
Kindly Suggest How to Solve this Problem.
You are trying to
Open a connection that is already open (most likely). We can help if you show the relevant part of your code.
The code is,
con.Open() cmd = New SqlCommand("SELECT COUNT(*)AS COUNTS FROM TABLE_NAME", con) cmd.ExecuteNonQuery() da = New SqlDataAdapter dr = cmd.ExecuteReader While dr.Read EMP_cnt = dr("counts") End While con.Close() EMP_id = "RD" & EMP_cnt con.Open() cmd = New SqlCommand("INSERT INTO TABLE_NAME VALUES('" & EMP_id & "','" + CMBVALUE.TEXT.Text + "',0)", con) cmd.ExecuteNonQuery() con.Close() MsgBox("Detail Added", MsgBoxStyle.Information) Call clear_EMP()