Jump to content

an0_nym0u5

Members
  • Posts

    1
  • Joined

  • Last visited

an0_nym0u5's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. The code seems to be broken, so here it is one again with updated links: ' Create dummy recordset. ' This demonstrastes: ' 1) How to append new field to a empty recordset. ' 2) How to add new values to those fields. ' 3) How to save the recordset as a xml file. ' ' Main sectionConst adVarChar = 200, adDate = 7' Other ADO Data Types http://www.w3schools.com/asp/ado_datatypes.aspConst adFldIsNullable = 32' adFldIsNullable hex value 20 = decimal value 32' You can define field attributes, for example you can enable null value in a field. ' More on field attributes:' http://www.devguru.com/technologies/ado/8763' http://www.devguru.com/technologies/ado/8601' https://msdn.microsoft.com/en-us/library/ms676553(v=VS.85).aspx' ' Create empty recordset. Set objRecordSet = NothingSet objRecordSet = CreateObject( "ADODB.Recordset" )' Create fields in recordset. ' syntax: {object}.Fields.Append Name, Type, DefineSize, Attrib, FieldValue ' http://www.devguru.com/Technologies/ado/qu...collection.htmlobjRecordSet.Fields.Append "MyField1", adVarChar, 20 ' Creating 20 characters long field. objRecordSet.Fields.Append "MyField2", adVarChar, 20objRecordSet.Fields.Append "MyDate1", adDate, ,adFldIsNullable' ' Open recordset. objRecordSet.Open' ' Fill in some values to the fields. For i = 1 to 3 objRecordSet.AddNew ' Add new record objRecordSet( "MyField1" ) = i & ". value in MyField1" ' Add values to the fields in the record. objRecordSet( "MyField2" ) = i & ". value in MyField2"' objRecordSet( "MyDate1" ) = null objRecordSet( "MyDate1" ) = Now() objRecordSet.UpdateNext' ' Pass the recordset to function, which shows the values of the fields of each record in the recordset. If ShowRecords(objRecordSet) Then ' ' Save the recordset as a xml file. objRecordSet.Save "dummy_recordset.xml", 1Else Wscript.Echo "Empty recordset. " & objRecordSet.RecordCountEnd If' End of main sectionFunction ShowRecords(objRecordSet)ShowRecords = FalseIf objRecordSet.RecordCount > 0 Then Wscript.Echo "Recordcount: " & objRecordSet.RecordCount objRecordSet.MoveFirst Do Until objRecordSet.EOF For Each strField in objRecordSet.Fields Wscript.Echo Trim(strField.Name) & "=" & strField.Value Next Wscript.Echo String(30, "-") objRecordSet.MoveNext ShowRecords = True LoopEnd IfEnd Function
×
×
  • Create New...