As error suggest you have opened datareader but you havent close it.. so just close it like;
If chklist.CheckOnClick = True Then
str1 = chklist.Text
End If
If lblCustCode.Text = "" Then
MessageBox.Show(" Please Select the CustomerCode ", strprjName, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If lblCustName.Text = "" Then
MessageBox.Show(" Please Select the CustomerName ", strprjName, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
If cb1.Text = "Select" Or cb1.Text = "" Then
MessageBox.Show(" Select the Payment Type ", strprjName, MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
com = New SqlCommand("select CustCode from tbl_Purchase where CustCode='" & lblCustCode.Text & "'", con)
dr = com.ExecuteReader
If dr.Read() Then
MessageBox.Show(" This Code Already Exists ", strprjName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
if NOT dr.IsClosed then
dr.Close()
cmd = New SqlCommand("insert into tbl_Purchase values('" & lblCustCode.Text & "','" & lblCustName.Text & "','" & str1 & "','" & TextBox1.Text & "','" & TextBox2.Text & "','" & cb1.Text & "'", con)
cmd.ExecuteNonQuery()
Purchase()
lblCustCode.Text = ""
lblCustName.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
cb1.Text = "Select"
End If
if NOT dr.IsClosed then
dr.Close()