S
Steven Thomas
Can some one help me find a code snipit for saving the contents of a
data set to a comma seperated file?
I have created a web service in asp.net that will read the data from a
AS/400 DB2 database via a OleDB connection. Then I create the
dataset, Now what do I do
Here is the function now
------------------------------------------------
Public Function GetTicketData() As DataSet
'Public Function GetTicketData(ByVal varbpno, ByVal
varAcctperdid) As DataSet
Dim RecLocName As String
Dim AuthNO As String
Dim TktRecDt As Date
Dim RcdVolQT As String
Dim RcdCullQT As String
Dim SpProd As String
REM -- get the data from the database
Dim sqlText As String = "select reclocnm, a.authno, tktrecdt,
rcdvolqt, rcdcullqt, sppdfmgd from "
sqlText = sqlText + " ticket a, tktdtl b, recloc c, spprod d ,
auth e where a.tktid = b.tktid and a.acctperdid = b.acctperdid"
sqlText = sqlText + " and a.reclocid = c.reclocid and
b.spprodid = d.spprodid and a.authno = e.authno"
sqlText = sqlText + " and e.splrbpno = 1 and a.acctperdid =
222"
'sqlText = sqlText + " and e.splrbpno = " + varbpno + " and
a.acctperdid = " + varAcctperdid
Dim dbRead As OleDb.OleDbDataReader = GetDataReader(sqlText)
REM -- create the datatable
Dim ds As DataSet = New DataSet("TicketInfo")
Dim dt As DataTable = ds.Tables.Add("TicketData")
Dim dr As DataRow
REM -- create the columns in the datatable
dt.Columns.Add(New DataColumn("RecLocName",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("AuthNO",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("TktRecDt",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("RcdVolQT",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("RcdCullQT",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("SpProd",
System.Type.GetType("System.String")))
While dbRead.Read()
RecLocName = dbRead.Item("RecLocNM").ToString()
AuthNO = dbRead.Item("AuthNO").ToString()
TktRecDt =
DateTime.Parse(dbRead.Item("TktRecDT").ToString())
RcdVolQT = dbRead.Item("RcdVolQT").ToString()
RcdCullQT = dbRead.Item("RcdCullQT").ToString()
SpProd = dbRead.Item("SPPDFMGD").ToString()
REM -- Add to DataSet ds
dr = dt.NewRow()
dt.Rows.Add(dr)
End While
'Return ds
End Function
data set to a comma seperated file?
I have created a web service in asp.net that will read the data from a
AS/400 DB2 database via a OleDB connection. Then I create the
dataset, Now what do I do
Here is the function now
------------------------------------------------
Public Function GetTicketData() As DataSet
'Public Function GetTicketData(ByVal varbpno, ByVal
varAcctperdid) As DataSet
Dim RecLocName As String
Dim AuthNO As String
Dim TktRecDt As Date
Dim RcdVolQT As String
Dim RcdCullQT As String
Dim SpProd As String
REM -- get the data from the database
Dim sqlText As String = "select reclocnm, a.authno, tktrecdt,
rcdvolqt, rcdcullqt, sppdfmgd from "
sqlText = sqlText + " ticket a, tktdtl b, recloc c, spprod d ,
auth e where a.tktid = b.tktid and a.acctperdid = b.acctperdid"
sqlText = sqlText + " and a.reclocid = c.reclocid and
b.spprodid = d.spprodid and a.authno = e.authno"
sqlText = sqlText + " and e.splrbpno = 1 and a.acctperdid =
222"
'sqlText = sqlText + " and e.splrbpno = " + varbpno + " and
a.acctperdid = " + varAcctperdid
Dim dbRead As OleDb.OleDbDataReader = GetDataReader(sqlText)
REM -- create the datatable
Dim ds As DataSet = New DataSet("TicketInfo")
Dim dt As DataTable = ds.Tables.Add("TicketData")
Dim dr As DataRow
REM -- create the columns in the datatable
dt.Columns.Add(New DataColumn("RecLocName",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("AuthNO",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("TktRecDt",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("RcdVolQT",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("RcdCullQT",
System.Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("SpProd",
System.Type.GetType("System.String")))
While dbRead.Read()
RecLocName = dbRead.Item("RecLocNM").ToString()
AuthNO = dbRead.Item("AuthNO").ToString()
TktRecDt =
DateTime.Parse(dbRead.Item("TktRecDT").ToString())
RcdVolQT = dbRead.Item("RcdVolQT").ToString()
RcdCullQT = dbRead.Item("RcdCullQT").ToString()
SpProd = dbRead.Item("SPPDFMGD").ToString()
REM -- Add to DataSet ds
dr = dt.NewRow()
dt.Rows.Add(dr)
End While
'Return ds
End Function