|
-
Jun 10th, 2004, 09:19 AM
#1
Thread Starter
Hyperactive Member
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.
-
Jun 10th, 2004, 07:26 PM
#2
Thread Starter
Hyperactive Member
-
Jun 10th, 2004, 08:29 PM
#3
Sleep mode
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 ....
-
Jun 10th, 2004, 08:42 PM
#4
Thread Starter
Hyperactive Member
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..
-
Jun 10th, 2004, 10:40 PM
#5
Sleep mode
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
-
Jun 11th, 2004, 12:31 AM
#6
Thread Starter
Hyperactive Member
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?
-
Jun 11th, 2004, 10:28 AM
#7
Sleep mode
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|