i am done with the insert query but have a problem in select query whenever i try to run i get the error that inveliad attempt to call reader when rd is close
i use module ,and put my sql opration code there and call it to another form
my code for module is :
Imports System.Data.SqlClient
Module Database_Module
Public sqlc As New SqlClient.SqlConnection("Data Source=AIS-QUARDCORE\SQLEXPRESS;Initial Catalog= Student Record App ;Integrated Security=True;multipleactiveresultsets = true ")
Dim sqlad As New SqlClient.SqlDataAdapter
Public rd As SqlDataReader
Public Function ExecuteSelect(ByVal Query As String, ByVal sqlc As System.Data.SqlClient.SqlConnection) As System.Data.DataTable
Dim cammad As New SqlCommand(Query, sqlc)
rd = cammad.ExecuteReader
Try
rd.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return Nothing
End Function
End Module
and the code where i want to call is on form load event .
ExecuteSelect("SELECT fldName FROM dbo.Test", sqlc)
While rd.Read
ListBox1.Items.Add("fldName")
End While
want to add data to listbox on load
plz help ......