Question 1 -- Data access technique: object or code?
I am very new to VB.NET and, specifically, ADO.NET, and am
coming from the
Access world <sigh>. In trying to learn about ADO.NET
I have seen that I
can either use "visual" objects that reside in
the system tray for the
connection object, command object, etc., or I can
instantiate these through
code. Nothing I have seen tells me which is better. Is
this truly a
matter of preference, or is one technique better than
another? Which
should I be more interested in learning?
Question 2 -- Data access technique: bound or unbound
controls?
In my Access travels I have learned that I am most
comfortable using
unbound controls. If I am to seriously learn "best
practices" in VB.NET I
would like to ask whether ADO.NET is a great environment for
bound controls
or if I should continue with the extra effort to code
unbound
controls. What do you veterans recommend?
Question 3 -- Is there a glaring error in the snippet I have
provided?
I have tried learning the coding technique with unbound
controls. I can
run the query (shown below) in SQL Server's Query Analyzer
and see the
appropriate data, but when I try to access it in VB.NET it
throws an error
that no data is present.
In the following code, at runtime intClientID evaluates to
1, which is
correct. The line before con.Close() throws an exception.
I know this is
choppy and I apologize for being so inexperienced, but is
there anything
obviously wrong (other than the fact that I should probably
use a data
adapter rather than a reader for this)?
Private Sub cboSavedClients_SelectedIndexChanged(ByVal
sender As
System.Object, ByVal e As System.EventArgs) Handles
cboSavedClients.SelectedIndexChanged
Dim intClientID As Integer
intClientID =
mstrClientArray(cboSavedClients.SelectedIndex)
con.Open()
cmd.CommandText = "SELECT ClientID, EntityID,
EntryTypeID,
ClientLName, ClientFName, ClientMName, " & _
"ClientSuffix, SpouseLName, SpouseFName,
SpouseMName,
SpouseSuffix, Inactive FROM ClientAdvantage." & _
"dbo.Clients WHERE ClientID = "
& intClientID
Dim dr As SqlDataReader = cmd.ExecuteReader
txtClientLName.Text = Trim(dr(0))
con.Close()
End Sub
Any assistance or answers to the first questions that you
could provide
would be most appreciated.
Jason
===================================
This list is hosted by DevelopMentorŪ http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com
|