Last post Oct 07, 2013 08:34 AM by oned_gk
Oct 07, 2013 08:12 AM|harkirat777|LINK
I just want to know what is the difference and what is a good practice of connecting to database:
1. Using ASP.NET Expression:
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Weekly_QAConnectionString %>" SelectCommand="SELECT * FROM [tbl_tests]"></asp:SqlDataSource>
Dim myCommand As New SqlCommand(mySelectQuery, myConnection)
Catch Ex As Exception
The former is very easy to write, visual studio creates ir automatically.
Oct 07, 2013 08:22 AM|bbcompent1|LINK
While option #1 gives you the ease of drag and drop pretty much, the second block is actually better as it allows for separation of concerns. It is alwasy best practice to separate the visual from the business logic. Intermingling them can create confusion,
plus the second option allows you to debug by setting break points in your code behind.
Oct 07, 2013 08:23 AM|Sekhar Prasad|LINK
This might help you
Oct 07, 2013 08:34 AM|oned_gk|LINK