Click here to Skip to main content
15,895,423 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Arrow keys to move an object Pin
ChandraRam3-Sep-12 4:00
ChandraRam3-Sep-12 4:00 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:25
Steven St. John3-Sep-12 7:25 
AnswerRe: Arrow keys to move an object Pin
Alan N3-Sep-12 6:00
Alan N3-Sep-12 6:00 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:32
Steven St. John3-Sep-12 7:32 
AnswerRe: Arrow keys to move an object Pin
Sonhospa3-Sep-12 7:14
Sonhospa3-Sep-12 7:14 
GeneralRe: Arrow keys to move an object Pin
Steven St. John3-Sep-12 7:35
Steven St. John3-Sep-12 7:35 
GeneralRe: Arrow keys to move an object Pin
Sonhospa3-Sep-12 21:30
Sonhospa3-Sep-12 21:30 
QuestionDataContext Not Updating Its Database Pin
Sonhospa31-Aug-12 23:16
Sonhospa31-Aug-12 23:16 
Hello everybody,

I'm trying to add records to the 'Customer' and the 'Item' classes of my DataContext. The Sub is part of the (partial) DataContext class. Adding new records seems to be a simple thing when I believe all the sources I read, but I'm obviously still wrong with something: 'SubmitChanges' doesn't update the underlying database... Confused | :confused: This despite the fact that all the DB records (old & new) are printed to the screen before, i.e. seem to be part of the 'Inserts' list. BTW, there are no exceptions thrown.

Can someone please tell me what's wrong with that code?
Public Sub InsertTest()

     Dim cust As New Customer                            ' add new customer
     With cust
         .First_Name = "Paul"
         .Last_Name = "Miller"
     End With
     Customer.InsertOnSubmit(cust)

     Dim item1 As New Item                               ' add new product item
     With item1
         .Item_Name = "DVD"
         .Item_Price = 19.75
     End With
     Item.InsertOnSubmit(item1)

     Dim item2 As New Item                               ' add new product item
     With item2
         .Item_Name = "BlueRay"
         .Item_Price = 29.75
     End With
     Item.InsertOnSubmit(item2)

     ' ONLY FOR DEBUGGING
     ' print changed objects
     Dim mySet As System.Data.Linq.ChangeSet = Me.GetChangeSet()
     Dim liste As Object = mySet.Inserts

     For Each entry As Object In liste                '<----- prints existing & added entries
         Select Case True
             Case TypeOf (entry) Is Item
                 Console.WriteLine(entry.Item_Name)
             Case TypeOf (entry) Is Customer
                 Console.WriteLine(entry.last_name)
             Case Else
                 Console.WriteLine("Objekt vom Typ '{0}'", entry.GetType.Name)
         End Select

     Next

     SubmitChanges()                                    '<---- isn't writing changes to database
     Console.ReadLine()

 End Sub


modified 3-Sep-12 17:46pm.

AnswerRe: DataContext Not Updating Its Database Pin
Sonhospa3-Sep-12 7:21
Sonhospa3-Sep-12 7:21 
QuestionToggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 6:27
juno10131-Aug-12 6:27 
AnswerRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 7:26
mveDave Kreskowiak31-Aug-12 7:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno10131-Aug-12 9:06
juno10131-Aug-12 9:06 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak31-Aug-12 9:26
mveDave Kreskowiak31-Aug-12 9:26 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
juno1011-Sep-12 17:49
juno1011-Sep-12 17:49 
GeneralRe: Toggling ON/OFF VB6 reference library in Visual Studio Pin
Dave Kreskowiak1-Sep-12 18:42
mveDave Kreskowiak1-Sep-12 18:42 
QuestionHow to insert an ID number to another table column Pin
garyu8730-Aug-12 20:56
garyu8730-Aug-12 20:56 
AnswerRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 22:24
professionalWayne Gaylard30-Aug-12 22:24 
GeneralRe: How to insert an ID number to another table column Pin
garyu8730-Aug-12 23:09
garyu8730-Aug-12 23:09 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard30-Aug-12 23:19
professionalWayne Gaylard30-Aug-12 23:19 
GeneralRe: How to insert an ID number to another table column Pin
Simon_Whale30-Aug-12 23:20
Simon_Whale30-Aug-12 23:20 
GeneralRe: How to insert an ID number to another table column Pin
garyu8731-Aug-12 0:12
garyu8731-Aug-12 0:12 
GeneralRe: How to insert an ID number to another table column Pin
Wayne Gaylard31-Aug-12 0:19
professionalWayne Gaylard31-Aug-12 0:19 
GeneralRe: How to insert an ID number to another table column Pin
garyu871-Sep-12 20:22
garyu871-Sep-12 20:22 
QuestionRemove controls from a form using For Each Pin
Steven St. John30-Aug-12 5:30
Steven St. John30-Aug-12 5:30 
AnswerRe: Remove controls from a form using For Each Pin
ChandraRam30-Aug-12 8:03
ChandraRam30-Aug-12 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.