Re: DAL Question: SqlConnection vs SqlDataSource



//Quote
Thanks again... I will be expecting to receive an invoice next week for
your services ;-)
//End Quote

The bill is already in the mail (ha ha).

...

I'm new to Linq myself.

Here is a free resource:
http://slickdeals.net/?pno=11351&lno=1&afsrc=1

However, I'm stuck in 2.0/3.0 land right now. Aka, no 3.5. So that
obviously affects my approach to things.

But LINQ takes a little time to get a hold of.


But based on what I've read so far, I' still pretty content where I'm at.
I'll get there one day as well.
And maybe reevaluate my whole approach.

But dude, when I came from VB6, I didn't get much help at all.
Then again, I didn't use newsgroups like these as much as I should have
either.

The most radical thing I learned was that "push xml down into tsql"
thing,...which really altered my approach to things.

Ok......happy hunting!

...


"John Kotuby" <johnk@xxxxxxxxxxxxx> wrote in message
news:e8ybMR7YIHA.5980@xxxxxxxxxxxxxxxxxxxxxxx
sloan,
I appreciate your effort on my behalf to get me started on the right
course to higher education.
It's amazing how sometimes good fortune seems to find one at just the
right time, provided you can keep your eyes and mind open.
There are too many people talking and too few listening.

I will study your code and the articles provided and make use of them.

I have read a good portion of the "bird's eye view" article and also
bookmarked it (as well as saving a DOC version for off-line reading),
before I had to get back to hacky hacky. We have a "dog and pony show" of
my program tomorrow to prospective clients, and I had to clean up the
rough edges.

I am hoping your method will stand the test of time and keep working while
other Microsoft fads come and go. I will be moving my codebase to VS 2008
soon. What I have read about LINQ so far is interesting and seems to offer
some similarity of purpose.

But before I can say that with ANY level of certainty I will try your code
examples. It's not often that one is offered solid working code examples
that are actually usable.

Thanks again... I will be expecting to receive an invoice next week for
your services ;-)

"sloan" <sloan@xxxxxxxxx> wrote in message
news:%236uMk14YIHA.208@xxxxxxxxxxxxxxxxxxxxxxx
Once you get the hang of it...and you use the DAAB 2.0 or the
EnterpriseLibrary.Data (3.1)...you'll find the DAL code to be very very
clean.

Here is some EnterpriseLibrary usage, in a DAL I have.

My update procedure has barely any lines in it at all. Just the barest
of necessities.

Once you write clean code like this (and it actually works as well
!!)..you never want to go back to
hacky hacky,...declaring sqlconnection and sqlcommand objects.
Clean DAL code is the best DAL code of all !

(keep scrolling too, i have another comment after the code)


//start code

using System;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

namespace GranadaCoder.Applications.BulkDataTransferExample.DAL
{

public class SqlServerPubsData
{

private readonly string PROC_TITLE_UPDATE = "dbo.uspTitleUpdate";

public SqlServerPubsData()
{
}


private Microsoft.Practices.EnterpriseLibrary.Data.Database
GetDatabase()
{

Database db = DatabaseFactory.CreateDatabase(); // Gets the DEFAULT
instance
return db;
}


public int TitleInfoUpdate( DataSets.TitlesDS ds)
{
try
{
Database db = this.GetDatabase(); //
DBCommandWrapper dbWrap = db.GetStoredProcCommandWrapper
(this.PROC_TITLE_UPDATE);
dbWrap.AddInParameter( "@xml_doc", DbType.String, ds.GetXml());
dbWrap.AddOutParameter( "@numberRowsAffected", DbType.Int32, 0 );
db.ExecuteNonQuery(dbWrap);
return Convert.ToInt32 (dbWrap.GetParameterValue(
"@numberRowsAffected"));

}
finally
{
}


}



}
}


//end code


Also....you may not know this.

http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/268be0e152d8b876

Look there. You can actually pass DataSet.GetXml() INTO a stored
procedure...and let tsql use it.
The url at google_groups I just gave shows the TSQL code for it.

Follow the MS KB's as well, and you can learn how to do BULK inserts and
updates.
I found that article a while back (2003?) and my post has a ...cleaned up
and nicer version of it.

Good luck. At least you started asking question before getting too deep
into the RAPID model.
::::wiping forehead with back of my hand::::::::: (ha ha)






.