Re: Please help!! How to get parameter back in ADO.NET
From: William \(Bill\) Vaughn (billvaRemoveThis_at_nwlink.com)
Date: 01/07/05
- Next message: W.G. Ryan eMVP: "Re: VB Ado.net timing issue"
- Previous message: Gerry: "Re: FillSchema works on one machine but not another???"
- In reply to: nashak_at_hotmail.com: "Please help!! How to get parameter back in ADO.NET"
- Next in thread: nashak_at_hotmail.com: "Re: Please help!! How to get parameter back in ADO.NET"
- Reply: nashak_at_hotmail.com: "Re: Please help!! How to get parameter back in ADO.NET"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 Jan 2005 15:17:20 -0800
First, we need a bit more information. What type of DBMS engine are you
using? Jet/Access, SQL Server, Oracle, 3x5Card?
Note the OUTPUT parameters ONLY work with stored procedures.
If you aren't using a SP, you need to query the newly created identity
value. http://www.betav.com/msdn_magazine.htm has an article that might
help.
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
<nashak@hotmail.com> wrote in message
news:1105131052.467233.153010@f14g2000cwb.googlegroups.com...
> Hi,
>
> We are not using Stored Procedures. I need to get back the value of the
> primary key (ID) field of the table once I've inserted a new record.
>
> I have a Insert statement as follows:
> cmdInsertStudy.CommandText = "Insert into " & TableName & "(" & _
> strCol & ") values (@p1, @p2, @p3, @p4,
> @p5, @p6, @p7) "
>
> i.e passing 7 parameters.
>
> cmdInsertStudy.CommandType = CommandType.Text
> daStudy.InsertCommand = cmdInsertStudy
>
> 'Created new parameter to get the value of the ID field that
> 'is generated by sql server
>
> Dim myParam As SqlParameter =
> daStudy.InsertCommand.Parameters.Add("@StudyID", SqlDbType.Int, 10,
> "StudyID")
> myParam.Direction = ParameterDirection.Output
>
> daStudy.InsertCommand.Transaction = trname
> daStudy.Update(dsEmptyStudy, TableName)
>
> What do I do now?
>
>
> Thanks
>
- Next message: W.G. Ryan eMVP: "Re: VB Ado.net timing issue"
- Previous message: Gerry: "Re: FillSchema works on one machine but not another???"
- In reply to: nashak_at_hotmail.com: "Please help!! How to get parameter back in ADO.NET"
- Next in thread: nashak_at_hotmail.com: "Re: Please help!! How to get parameter back in ADO.NET"
- Reply: nashak_at_hotmail.com: "Re: Please help!! How to get parameter back in ADO.NET"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|