Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 86,243 VB Programmers. There are 2,269 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a VB Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Linq, insert a line into a db with a auto generated primary key

 
Reply to this topicStart new topic

Linq, insert a line into a db with a auto generated primary key

drjacky
post 25 Apr, 2008 - 02:06 AM
Post #1


New D.I.C Head

*
Joined: 25 Apr, 2008
Posts: 2



Hi,

I'm working with VS2008 & Linq and I would like to insert a line into my table called ISAMEMBEROF. The problem is that the primary key (IMO_ID) must be generated automatically (varchar 36). Here is the code that I wrote :

CODE

Dim msg1 As Integer = USRDataGridView.CurrentCell.RowIndex
Dim msg2 As Integer = GROUPDataGridView.CurrentCell.RowIndex

' Create a new object.
Dim ord As New ISAMEMBEROF With _
{.USR_SID = USRDataGridView.Rows(msg1).Cells(0).Value, _
.GRP_GID = USRDataGridView.Rows(msg2).Cells(0).Value, _
.IMO_ID = ???}

' Add the new object to the collection.
Me.Db.ISAMEMBEROFs.InsertOnSubmit(ord)

' Submit the change to the database.
Try
Db.SubmitChanges()
Catch except As Exception
Console.WriteLine(except)
Db.SubmitChanges()
End Try


The SQL equivalent would be :
CODE

insert into ISAMEMBEROF (IMO_ID, USR_SID, GRP_GID) values (default, ..........)


How to do to get this with VB.NET/Linq ?

TIA smile.gif


Etienne
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


drjacky
post 8 May, 2008 - 11:47 PM
Post #2


New D.I.C Head

*
Joined: 25 Apr, 2008
Posts: 2

resolved, thanks ! biggrin.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 08:22AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month