Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vb.net linq Insert new record

Im trying to insert a new record though linq. im able to update and read data with out any problem.but i just cant figure out how to just inset a new record. here is a start of my function. i know its not done yeat. all help would be nice.

Public Function AddAddressInfo(ByVal objdeptGUID As String, ByVal objGEOCode As String, ByVal objArressCommonName As String, ByVal objStreetAddress As String, ByVal objAddressNotes As String, ByVal objIsPublic As Boolean, ByVal objSesionToken As String)
    ''#Check of Token is good
    If CheckToken(objSesionToken, objdeptGUID) = False Then
        Return "Error"
    End If

    Try
        Dim lqAlarms As New linqAlarmDumpDataContext
        Dim AddInfo = From r In lqAlarms.tbAddressInfos
                      Where r.DeptGUID = objdeptGUID
                      Select r
    Catch ex As Exception

    End Try
End Function
like image 541
Ghsotwalker42 Avatar asked Aug 01 '11 02:08

Ghsotwalker42


1 Answers

Use the InsertOnSubmit() and SubmitChanges() to insert your records.

Dim lqAlarms As New linqAlarmDumpDataContext
Dim info As New tbAddressInfo With { ... }    ' Create the record
lqAlarms.tbAddressInfos.InsertOnSubmit(info)  ' Insert the record
lqAlarms.SubmitChanges()                      ' Commit the insertion
like image 125
user807566 Avatar answered Nov 16 '22 12:11

user807566