Results 1 to 7 of 7

Thread: DataSet Question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    DataSet Question

    Maybe one of you can help me..

    How do I clone the structure of a table into a dataset without populating the dataset.. Basically I want to take a dataset and make it have all the fields of a specific table without having to Fill it.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Anybody?

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Hinder
    Anybody?
    One way is to populate the dataset then use the method .WriteXMLSchema or something like this . It outputs an XML file that contains the structure only . You can use ReadXMLSchema to skin in the new dataset . Apparently you don't want to do this though ....

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Originally posted by Pirate
    One way is to populate the dataset then use the method .WriteXMLSchema or something like this . It outputs an XML file that contains the structure only . You can use ReadXMLSchema to skin in the new dataset . Apparently you don't want to do this though ....
    Ah ok, so I only have to do this once then I can just load it from the schema right? Hmm so this only needs to be done everytime the original database table structure has been modified.. Ill try it, thanks Pirate..

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Hinder
    Ah ok, so I only have to do this once then I can just load it from the schema right? Hmm so this only needs to be done everytime the original database table structure has been modified.. Ill try it, thanks Pirate..
    Yes . That's all theoritically speaking

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Ok what am I missing here.. It doesn't error out but it's not adding the new data to the database..

    Code:
        Public Function SaveAccount(ByVal inAcct As IO_Client) As Boolean
    
            Dim oConn As New SqlConnection(oCS)
            Dim strSQL As String = "SELECT * FROM Accounts"
            Dim oAdapter As New SqlDataAdapter(strSQL, oConn)
            Dim ds As New DataSet
    
            Try
                'Import the table design
                ds.ReadXmlSchema(Application.StartupPath & "\schemas\accounts.xml")
    
                'Let's make a new row
                Dim dr As DataRow = ds.Tables("Accounts").NewRow
    
                'Add the values to the row
                dr("AcctName") = inAcct.Account.AcctName
                dr("AcctPass") = inAcct.Account.AcctPass
                dr("AcctMail") = inAcct.Account.AcctMail
                dr("AcctBanned") = CType(inAcct.Account.AcctBanned, Byte)
                dr("AcctCreated") = inAcct.Account.AcctCreated
                dr("AcctPurge") = inAcct.Account.AcctPurge
                dr("AcctLastIP") = inAcct.Account.AcctLastIP
    
                'Update the database
                oAdapter.Update(ds, "Accounts")
    
    
            Catch ex As Exception
                MsgBox(ex.Message)
                Return False
            Finally
                'Close the connection
                oConn.Close()
            End Try
    
        End Function

    Don't I need to have some kind of command builder here to have this work?

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Yes . It generates all the commands for updating , deleting, insert .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width