Click here to Skip to main content
15,916,019 members
Home / Discussions / Database
   

Database

 
AnswerRe: .NET assembly in SQL Server 2005 Pin
Wendelius11-Dec-08 7:22
mentorWendelius11-Dec-08 7:22 
QuestionMerge cells in query result Pin
dan!sh 10-Dec-08 18:31
professional dan!sh 10-Dec-08 18:31 
AnswerRe: Merge cells in query result Pin
Mycroft Holmes10-Dec-08 20:22
professionalMycroft Holmes10-Dec-08 20:22 
GeneralRe: Merge cells in query result Pin
dan!sh 10-Dec-08 21:00
professional dan!sh 10-Dec-08 21:00 
GeneralRe: Merge cells in query result Pin
Mycroft Holmes10-Dec-08 21:44
professionalMycroft Holmes10-Dec-08 21:44 
QuestionMirror changed DataTable to old DataTable (ADO.NET) Pin
David Hovey10-Dec-08 10:22
David Hovey10-Dec-08 10:22 
AnswerRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
Wendelius10-Dec-08 10:39
mentorWendelius10-Dec-08 10:39 
GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
David Hovey10-Dec-08 11:15
David Hovey10-Dec-08 11:15 
I was reluctant to post code since it might not make a lot of sense. Here it is though. Toward the end of EditCongregation is where I want to update m_dsData with the modified DataRow...

Thanks again.

Private m_dsData As DataSet
Public Sub LoadData()

    'MsgBox("Legacy function LoadData() called.")
    Dim dbDataAdapter As OleDbDataAdapter
    dbDataAdapter = New OleDbDataAdapter()

    Try
        m_dsData = Nothing
        m_dsData = New DataSet

        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Congregations", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Congregations")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM HomeTalks", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "HomeTalks")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM CongregationSpeakers", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "CongregationSpeakers")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM CongregationSpeakerOutlines", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "CongregationSpeakerOutlines")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Outlines", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Outlines")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM OutlineCategories", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "OutlineCategories")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Readers", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Readers")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Chairmen", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Chairmen")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Hospitality", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Hospitality")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM AwayTalks", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "AwayTalks")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Notes", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Notes")
        dbDataAdapter.SelectCommand = New OleDbCommand("SELECT * FROM Conductors", m_dbConnection)
        dbDataAdapter.Fill(m_dsData, "Conductors")

        dbDataAdapter.Dispose()
    Catch ex1 As Data.DataException
        MsgBox("A data exception occured while loading data." & vbCr & "Description: " & ex1.Message, MsgBoxStyle.Exclamation)

        m_dbConnection.Close()
        m_dbConnection.Dispose()
        DbDataAdapter.Dispose()
    Catch ex2 As System.Exception
        MsgBox("A system exception occured while loading data." & vbCr & "Description: " & ex2.Message, MsgBoxStyle.Exclamation)

        m_dbConnection.Close()
        m_dbConnection.Dispose()
        DbDataAdapter.Dispose()
    End Try

End Sub
Public Function EditCongregation(ByVal rCongo As Congregation) As Notification

    Dim da As OleDbDataAdapter ', daSpeakers As OleDbDataAdapter
    Dim dt As New DataTable
    Dim dr As DataRow
    Dim commandBuilder As Data.OleDb.OleDbCommandBuilder
    Dim drCongos() As DataRow

    'Dim dtSpeakers As New DataTable

    drCongos = m_dsData.Tables("Congregations").Select("CongregationName = '" & rCongo.Name & "'")

    If UBound(drCongos) > -1 Then
        If UBound(drCongos) > 0 Then
            Return Notification.SevereError
        End If

        If Not drCongos(0).Item("ID") = rCongo.RecordID Then
            Return Notification.CongregationAlreadyExist
        End If
    End If

    'da = New OleDbDataAdapter("SELECT ID, CongregationName, KingdomHallAddress, Coordinator, CoordinatorHome, " & _
    '    "CoordinatorMobile, CoordinatorEmail, MeetingDay, MeetingTime, KingdomHallPhone FROM Congregations " & _
    '    "WHERE ID = " & rCongo.RecordID, m_dbConnection)
    da = New OleDbDataAdapter("SELECT ID, CongregationName, KingdomHallAddress, Coordinator, CoordinatorHome, " & _
        "CoordinatorMobile, CoordinatorEmail, MeetingDay, MeetingTime, KingdomHallPhone FROM Congregations", m_dbConnection)
    da.Fill(dt)
    'da = New OleDbDataAdapter("SELECT ID, CongregationName, KingdomHallAddress, Coordinator, CoordinatorHome, " & _
    '   "CoordinatorMobile, CoordinatorEmail, MeetingDay, MeetingTime, KingdomHallPhone " & _
    '    "FROM Congregations", m_dbConnection)
    'da.Fill(dt)

    commandBuilder = New OleDbCommandBuilder(da)

    drCongos = dt.Select("ID = " & rCongo.RecordID)

    'daCongo = New OleDbDataAdapter("SELECT CongregationName, Speaker, Coordinator, SpeakerHome, " & _
    '    "SpeakerMobile, SpeakerEmail, MeetingDay, MeetingTime, KingdomHallPhone FROM CongregationSpeakers " & _
    '    "WHERE CongregationName = '" & strName & "'", m_dbConnection)
    If UBound(drCongos) = -1 Then
        EditCongregation = Notification.CongregationNotFound
    ElseIf UBound(drCongos) > 0 Then
        EditCongregation = Notification.SevereError
    Else
        dr = drCongos(0)

        dr.Item("CongregationName") = rCongo.Name
        dr.Item("Coordinator") = rCongo.Coordinator
        dr.Item("CoordinatorEmail") = rCongo.CoordinatorEmail
        dr.Item("CoordinatorHome") = rCongo.CoordinatorHome
        dr.Item("CoordinatorMobile") = rCongo.CoordinatorMobile
        dr.Item("KingdomHallAddress") = rCongo.KingdomHallAddress
        dr.Item("KingdomHallPhone") = rCongo.KingdomHallPhone
        dr.Item("MeetingDay") = rCongo.MeetingDay
        dr.Item("MeetingTime") = rCongo.MeetingTime

        da.Update(dt)

        m_dsData.Tables.Remove("Congregations")
        da.Fill(m_dsData, "Congregations")

        EditCongregation = Notification.Successful
    End If

End Function

GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
Wendelius10-Dec-08 11:25
mentorWendelius10-Dec-08 11:25 
GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
David Hovey10-Dec-08 11:31
David Hovey10-Dec-08 11:31 
GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
Wendelius10-Dec-08 11:45
mentorWendelius10-Dec-08 11:45 
GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
David Hovey10-Dec-08 18:28
David Hovey10-Dec-08 18:28 
GeneralRe: Mirror changed DataTable to old DataTable (ADO.NET) Pin
Wendelius11-Dec-08 4:23
mentorWendelius11-Dec-08 4:23 
QuestionSQL case function to check for charindex as '' or ',' Pin
Trustapple10-Dec-08 8:17
Trustapple10-Dec-08 8:17 
AnswerRe: SQL case function to check for charindex as '' or ',' Pin
Wendelius10-Dec-08 8:29
mentorWendelius10-Dec-08 8:29 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Trustapple10-Dec-08 8:48
Trustapple10-Dec-08 8:48 
GeneralRe: SQL case function to check for charindex as '' or ',' [modified] Pin
Wendelius10-Dec-08 8:58
mentorWendelius10-Dec-08 8:58 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Trustapple10-Dec-08 9:35
Trustapple10-Dec-08 9:35 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Wendelius10-Dec-08 9:41
mentorWendelius10-Dec-08 9:41 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Trustapple10-Dec-08 18:58
Trustapple10-Dec-08 18:58 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Trustapple10-Dec-08 19:00
Trustapple10-Dec-08 19:00 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Ben Fair10-Dec-08 9:40
Ben Fair10-Dec-08 9:40 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Wendelius10-Dec-08 9:52
mentorWendelius10-Dec-08 9:52 
GeneralRe: SQL case function to check for charindex as '' or ',' Pin
Ben Fair10-Dec-08 10:06
Ben Fair10-Dec-08 10:06 
GeneralRe: SQL case function to check for charindex as '' or ',' [modified] Pin
Trustapple10-Dec-08 19:02
Trustapple10-Dec-08 19:02 

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.