Database Link

Results 1 to 4 of 4

Thread: Database Link

  1. #1
    Tony Guest

    Default Database Link

    How do I set a link to a database to XML in order that the contents of fields in the database are published in the XML document

  2. #2
    Mamata Tripathy Guest

    Default RE: Database Link

    Hi,<BR>You can find the code below useful. I tested the same using pubs database.<BR><BR>*****************<BR>&#060;%@ LANGUAGE="VBSCRIPT" %&#062;<BR>&#060;%Option Explicit%&#062;<BR>&#060;%<BR>Dim Conn<BR>Dim XMLObj<BR>Dim strSQL<BR>Dim rsAuthors<BR>Dim Authors<BR>Dim Author<BR>Dim AuthorID<BR>Dim AuthLastName<BR>Dim AuthFirstName<BR>Dim AuthPhone<BR>Dim AuthAddress<BR>Dim AuthCity<BR>Dim AuthState<BR>Dim AuthZIP<BR>Dim AuthContract<BR>Dim xmlPath<BR>Dim xslPath<BR>Dim styleXMLDoc<BR>Dim sourceXMLDoc<BR><BR>Set Conn = Server.CreateObject("ADODB.Connection")<BR>Conn.Op en "DSN=pubs;UID=sa;PWD="<BR>strSQL = "select * from Authors"<BR>Set rsAuthors = Conn.Execute(strSQL)<BR><BR>Set XMLObj = Server.CreateObject("Microsoft.XMLDOM")<BR>If (XMLObj.childNodes.length = 0) Then<BR><BR>Set Authors = XMLObj.createNode("element", "authors", "")<BR>XMLObj.appendChild(Authors)<BR><BR>rsAuthor s.MoveFirst<BR>Do While not (rsAuthors.eof)<BR> Set Author = XMLObj.createNode("element", "author", "")<BR> Authors.appendChild(Author)<BR> Set AuthorID = XMLObj.createNode("element", "authorid", "")<BR> AuthorID.Text = rsAuthors("au_id")<BR> Authors.appendChild(AuthorID)<BR> Set AuthLastName = XMLObj.createNode("element", "authlastname", "")<BR> AuthLastName.Text = rsAuthors("au_lname")<BR> Authors.appendChild(AuthLastName)<BR> Set AuthFirstName = XMLObj.createNode("element", "authfirstname", "")<BR> AuthFirstName.Text = rsAuthors("au_fname")<BR> Authors.appendChild(AuthFirstName)<BR> Set AuthPhone = XMLObj.createNode("element", "authphone", "")<BR> AuthPhone.Text = rsAuthors("phone")<BR> Authors.appendChild(AuthPhone)<BR> Set AuthAddress = XMLObj.createNode("element", "authaddress", "")<BR> AuthAddress.Text = rsAuthors("address")<BR> Authors.appendChild(AuthAddress)<BR> Set AuthCity = XMLObj.createNode("element", "authcity", "")<BR> AuthCity.Text = rsAuthors("city")<BR> Authors.appendChild(AuthCity)<BR> Set AuthState = XMLObj.createNode("element", "authstate", "")<BR> AuthState.Text = rsAuthors("state") <BR> Authors.appendChild(AuthState)<BR> Set AuthZIP = XMLObj.createNode("element", "authzip", "")<BR> AuthZIP.Text = rsAuthors("zip") <BR> Authors.appendChild(AuthZIP)<BR> Set AuthContract = XMLObj.createNode("element", "authcontract", "")<BR> AuthContract.Text = rsAuthors("contract") <BR> Authors.appendChild(AuthContract)<BR>rsAuthors.Mov eNext<BR>Loop<BR>rsAuthors.close<BR>Set rsAuthors = Nothing<BR><BR>End If<BR>& Server.MapPath("authors.xml")<BR>"auth ors.xml")<BR>Response.Write("authors.xml created successfully<BR>")<BR><BR>****************

  3. #3
    Join Date
    Dec 1969

    Default NOW WHAT??????

    OK,<BR>I used your code and slightly modified it to hook up with my DB, but where does the authors.xml file get saved to. The code executed and I got the "file created successfully" but I cant find the file?<BR><BR>Please help<BR>Thanks

  4. #4
    Join Date
    Dec 1969

    Default Don't shout :)

    & Server.MapPath("authors.xml") <BR>"authors.xml") <BR><BR> The first line in the code was commented out, but you could uncomment it to write the XML to the server&#039s MapPath. But I believe the default for is the Windows or Windows System folder. Try either one of those.<BR><BR> Or try searching your hard drive. :P<BR><BR> Another thought, you could always use a hard-coded path"c: empauthors.xml")<BR><BR> - Jeff

Posting Permissions

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