Declan Basile
asked on
Why does the data adapter work but the reader does not?
If this works
Dim strRootNodeName As String
Dim dt As New DataTable
Using cn As New SqlConnection(GlobalVariab les.strCon n)
Using cmd As New SqlCommand(m_strNameLookup SQL, cn)
cmd.Parameters.Add("@ItemI d", SqlDbType.Int).Value = m_RootNodeId
Using da As New SqlDataAdapter(cmd)
da.Fill(dt)
strRootNodeName = dt.Rows(0)("ItemName")
End Using
End Using
End Using
Why would this not work?
Dim strRootNodeName As String
Using cn As New SqlConnection(GlobalVariab les.strCon n)
Using cmd As New SqlCommand(m_strNameLookup SQL, cn)
cmd.Parameters.Add("@ItemI d", SqlDbType.Int).Value = m_RootNodeId
Using rdr = cmd.ExecuteReader
rdr.Read()
strRootNodeName = rdr("ItemName")
End Using
End Using
End Using
Dim strRootNodeName As String
Dim dt As New DataTable
Using cn As New SqlConnection(GlobalVariab
Using cmd As New SqlCommand(m_strNameLookup
cmd.Parameters.Add("@ItemI
Using da As New SqlDataAdapter(cmd)
da.Fill(dt)
strRootNodeName = dt.Rows(0)("ItemName")
End Using
End Using
End Using
Why would this not work?
Dim strRootNodeName As String
Using cn As New SqlConnection(GlobalVariab
Using cmd As New SqlCommand(m_strNameLookup
cmd.Parameters.Add("@ItemI
Using rdr = cmd.ExecuteReader
rdr.Read()
strRootNodeName = rdr("ItemName")
End Using
End Using
End Using
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not a problem Declan_Basile, glad to help.
ASKER