[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.inetserver.asp.db

Michael kors outlet zu89

Katadedajab

12/28/2013 7:03:00 PM

<a href=http://www.bessforless.com/mkoutlet.html><b&... kors outlet</b></a>I know aspect is painful gorgeous honeymoons as well all your family members but take heart about whether or not your family really benefit from him,let him are.<a href=http://www.bessforless.com/mkoutlet.html><b&... kors outlet</b></a>Greetings! I are aware of that this tends to be that somewhat off topic but take heart I was wondering about whether or not your family knew where I may locate an all in one captcha plugin along with my very own comment form? I'm making use of their going to be the same web site platform as yours and I'm having difficulty finding a minumum of one Thanks a parcel!<a href=http://www.financialmedic.com/mk.html><b&... kors factory outlet</b></a>Having been learning, teaching and making use of their English as have the desired effect language along with around 10 years I am quite confident that I am a in line with the English user. I am quite interested for the reason that task. Please i am about to are aware of that about whether or not all your family members think I am qualified, please send my hand a multi functional message. I\'d a little as though to learn more about learn a great deal more about going to be the task and your website.<a href=http://www.financialmedic.com/mk.html><b&... kors outlet</b></a>It is always that routinely checked living upon a multi function detatched house or at least bungalow because a resource box will be the single are diverse having an all in one much in the way homely what better way and best including all of them are have their original garden and yard for more information on be well advised these fruits or even vegetables. Older people loves any of those making the rounds space and the chance to educate yourself regarding do best something.<a href=http://www.tpointsolutions.net/mkbags.html><b&... kors outlet online</b></a>
5 Answers

Miha Markic

12/4/2007 9:54:00 PM

0


"benji" <benji@discussions.microsoft.com> wrote in message
news:0D4D5A82-0271-4E4E-AADC-282B662E4129@microsoft.com...
> Hi Miha,
>
> 2 followup questions:
>
> 1) Would I not need a stored procedure for a compound SQL stamement?

No, you can have more than one statement in commandtext (depending on the
provider, sql can handle multiple statements)

> 2) After I have that in place, where would I retrieve the value in the
> data
> access layer?

Depends on the mappings associated with DataAdapter.

HTH
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_...

> Thanks..
>
> -Ben
>
>
> "Miha Markic" wrote:
>
>> You should check out the definition of myCustomersAdapter.InsertCommand -
>> it
>> should have ;SELECT Scope_Identity() at the end or something like that.
>>
>> --
>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_...
>>
>> "benji" <benji@discussions.microsoft.com> wrote in message
>> news:0C418196-09A0-45F5-897D-0A9EFC0A4C87@microsoft.com...
>> > Hi,
>> >
>> > I'm using VS2008, and the dataset designer to access my SQL Server 2005
>> > DB.
>> > I can insert a row into a table and then call the adapter to update. No
>> > problem, except I want to get back the ID field of the newly created
>> > row.
>> > I've tried the following:
>> >
>> > DataSet1.CustomersRow myrow = myCustomersTable.NewCustomersRow();
>> > myrow.field1 = "xyz"
>> >
>> > myCustomersTable.AddCustomersRow(myrow);
>> > myCustomersAdapter.Update(myCustomersTable);
>> >
>> > Label1.Text = myrow.NonGroupChellengeID.ToString()
>> >
>> > This returns -1. I can get the right value if I access the row directly
>> > on
>> > the datatable after calling update, but as it stands I just access the
>> > last
>> > row, and that might not be clean. ANy suggestions for this? I have to
>> > imagine
>> > this is a common scenario?
>> >
>> > Thanks...
>> >
>> > -Ben
>>
>>

benji

12/5/2007 3:04:00 AM

0

Hi Miha,

I added another query to the table, which was an insert query. I then
appended:

;SELECT Scope_Identity()

it compiled fine. It generated the expected insert method in the
tableadapter class, and the signature had it returning an int. However, the
int always returns 1 (probably indicating success). Could you go into more
detail regarding what you mean by " Depends on the mappings associated with
DataAdapter."? Thanks...

-Ben



"Miha Markic" wrote:

>
> "benji" <benji@discussions.microsoft.com> wrote in message
> news:0D4D5A82-0271-4E4E-AADC-282B662E4129@microsoft.com...
> > Hi Miha,
> >
> > 2 followup questions:
> >
> > 1) Would I not need a stored procedure for a compound SQL stamement?
>
> No, you can have more than one statement in commandtext (depending on the
> provider, sql can handle multiple statements)
>
> > 2) After I have that in place, where would I retrieve the value in the
> > data
> > access layer?
>
> Depends on the mappings associated with DataAdapter.
>
> HTH
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_...
>
> > Thanks..
> >
> > -Ben
> >
> >
> > "Miha Markic" wrote:
> >
> >> You should check out the definition of myCustomersAdapter.InsertCommand -
> >> it
> >> should have ;SELECT Scope_Identity() at the end or something like that.
> >>
> >> --
> >> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> >> RightHand .NET consulting & development www.rthand.com
> >> Blog: http://cs.rthand.com/blogs/blog_with_...
> >>
> >> "benji" <benji@discussions.microsoft.com> wrote in message
> >> news:0C418196-09A0-45F5-897D-0A9EFC0A4C87@microsoft.com...
> >> > Hi,
> >> >
> >> > I'm using VS2008, and the dataset designer to access my SQL Server 2005
> >> > DB.
> >> > I can insert a row into a table and then call the adapter to update. No
> >> > problem, except I want to get back the ID field of the newly created
> >> > row.
> >> > I've tried the following:
> >> >
> >> > DataSet1.CustomersRow myrow = myCustomersTable.NewCustomersRow();
> >> > myrow.field1 = "xyz"
> >> >
> >> > myCustomersTable.AddCustomersRow(myrow);
> >> > myCustomersAdapter.Update(myCustomersTable);
> >> >
> >> > Label1.Text = myrow.NonGroupChellengeID.ToString()
> >> >
> >> > This returns -1. I can get the right value if I access the row directly
> >> > on
> >> > the datatable after calling update, but as it stands I just access the
> >> > last
> >> > row, and that might not be clean. ANy suggestions for this? I have to
> >> > imagine
> >> > this is a common scenario?
> >> >
> >> > Thanks...
> >> >
> >> > -Ben
> >>
> >>
>
>

Miha Markic

12/5/2007 8:32:00 AM

0

Here is the idea

a) you'd need a mapping between database column and your column, i.e. (Id
<=> Id):
adapter.TableMapping.ColumnMappings.Add("Id", "Id");
b) you'd append this statement after the insert:
SELECT Id = SCOPE_IDENTITY()

BTW all this code is generated for you, if you drag & drop a table from
Server Explorer to dataset designer - you could try and see what code it
generates.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_...

"benji" <benji@discussions.microsoft.com> wrote in message
news:1F0FCA65-3644-4A5A-9DC8-7654D2A23BC9@microsoft.com...
> Hi Miha,
>
> I added another query to the table, which was an insert query. I then
> appended:
>
> ;SELECT Scope_Identity()
>
> it compiled fine. It generated the expected insert method in the
> tableadapter class, and the signature had it returning an int. However,
> the
> int always returns 1 (probably indicating success). Could you go into more
> detail regarding what you mean by " Depends on the mappings associated
> with
> DataAdapter."? Thanks...

benji

12/5/2007 3:09:00 PM

0

Hi Miha,

I already have this mapping in place for the uniqueid column. When I do a
fill, I can access the value for every row through the generated dataset
class. But it seems I can't access it through my generated Query, despite
appending
;SELECT ID = Scope_Identity()
The method generated simply returns an int for success or failure of
insertion. I'm not sure how having the UniqueID mapped into the table helps
in this way?

"Miha Markic" wrote:

> Here is the idea
>
> a) you'd need a mapping between database column and your column, i.e. (Id
> <=> Id):
> adapter.TableMapping.ColumnMappings.Add("Id", "Id");
> b) you'd append this statement after the insert:
> SELECT Id = SCOPE_IDENTITY()
>
> BTW all this code is generated for you, if you drag & drop a table from
> Server Explorer to dataset designer - you could try and see what code it
> generates.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_...
>
> "benji" <benji@discussions.microsoft.com> wrote in message
> news:1F0FCA65-3644-4A5A-9DC8-7654D2A23BC9@microsoft.com...
> > Hi Miha,
> >
> > I added another query to the table, which was an insert query. I then
> > appended:
> >
> > ;SELECT Scope_Identity()
> >
> > it compiled fine. It generated the expected insert method in the
> > tableadapter class, and the signature had it returning an int. However,
> > the
> > int always returns 1 (probably indicating success). Could you go into more
> > detail regarding what you mean by " Depends on the mappings associated
> > with
> > DataAdapter."? Thanks...
>
>

benji

12/5/2007 3:31:00 PM

0

Hi Miha,

I found the solution. After creating the query, I had to go to its
properties and change "ExecuteMode" from nonquery to scalar.

Best,

-Ben

"benji" wrote:

> Hi Miha,
>
> I already have this mapping in place for the uniqueid column. When I do a
> fill, I can access the value for every row through the generated dataset
> class. But it seems I can't access it through my generated Query, despite
> appending
> ;SELECT ID = Scope_Identity()
> The method generated simply returns an int for success or failure of
> insertion. I'm not sure how having the UniqueID mapped into the table helps
> in this way?
>
> "Miha Markic" wrote:
>
> > Here is the idea
> >
> > a) you'd need a mapping between database column and your column, i.e. (Id
> > <=> Id):
> > adapter.TableMapping.ColumnMappings.Add("Id", "Id");
> > b) you'd append this statement after the insert:
> > SELECT Id = SCOPE_IDENTITY()
> >
> > BTW all this code is generated for you, if you drag & drop a table from
> > Server Explorer to dataset designer - you could try and see what code it
> > generates.
> >
> > --
> > Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> > RightHand .NET consulting & development www.rthand.com
> > Blog: http://cs.rthand.com/blogs/blog_with_...
> >
> > "benji" <benji@discussions.microsoft.com> wrote in message
> > news:1F0FCA65-3644-4A5A-9DC8-7654D2A23BC9@microsoft.com...
> > > Hi Miha,
> > >
> > > I added another query to the table, which was an insert query. I then
> > > appended:
> > >
> > > ;SELECT Scope_Identity()
> > >
> > > it compiled fine. It generated the expected insert method in the
> > > tableadapter class, and the signature had it returning an int. However,
> > > the
> > > int always returns 1 (probably indicating success). Could you go into more
> > > detail regarding what you mean by " Depends on the mappings associated
> > > with
> > > DataAdapter."? Thanks...
> >
> >