Create new XML document
Dim MyConn, SQL_query,ResultSet,myName
'Open database connection
Set MyConn = CreateObject("ADODB.Connection")
MyConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\emp.mdb"
'Define the SQL query
SQL_query = "SELECT emp_name FROM employee"
'Execute the query and store results in ResultSet
Set ResultSet = MyConn.Execute(SQL_query)
ResultSet.MoveFirst
xmlResult = ""
'Read results from ResultSet in a loop
While NOT ResultSet.EOF
Set name1 = ResultSet("emp_name")
xmlResult= addXmlTag("emp_name",name1,xmlResult)
xmlResult = xmlResult & VBNullString
MsgBox xmlResult
ResultSet.MoveNext
WEND
xmlResult = xmlResult & VBNullString & " "
MsgBox xmlResult
'Release resources
ResultSet.close
MyConn.close
Function addXmlTag(colName,colValue,xmlResult)
startTag ="<"
endTag=">"
xmlResult = xmlResult & startTag & colName & endTag & colValue & startTag & colName & endTag
addXmlTag = xmlResult
End Function
'Open database connection
Set MyConn = CreateObject("ADODB.Connection")
MyConn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\emp.mdb"
'Define the SQL query
SQL_query = "SELECT emp_name FROM employee"
'Execute the query and store results in ResultSet
Set ResultSet = MyConn.Execute(SQL_query)
ResultSet.MoveFirst
xmlResult = "
'Read results from ResultSet in a loop
While NOT ResultSet.EOF
Set name1 = ResultSet("emp_name")
xmlResult= addXmlTag("emp_name",name1,xmlResult)
xmlResult = xmlResult & VBNullString
MsgBox xmlResult
ResultSet.MoveNext
WEND
xmlResult = xmlResult & VBNullString & "
MsgBox xmlResult
'Release resources
ResultSet.close
MyConn.close
Function addXmlTag(colName,colValue,xmlResult)
startTag ="<"
endTag=">"
xmlResult = xmlResult & startTag & colName & endTag & colValue & startTag & colName & endTag
addXmlTag = xmlResult
End Function
1 Comments:
All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
SAP training in Chennai
Post a Comment
<< Home