473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

dataset with streamwriter

hi

i have two datasets , one will return all employees belong to supervisor, and the other one will select all the documents belong to the temployees and write it to the files that have the filename start with EmpNo. what should i do ? ( i want to select all the file belong to each employee and write it to the file on server that has the filename start with the empNo )

Here is my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim objDataset As Data.DataSet
  3.         Dim objRow As Data.DataRow
  4.         Dim i As Long
  5.         Dim ds2 As DataSet
  6.         Dim ds As New DataSet
  7.         Dim j As Long
  8.         Dim dr As Data.DataRow
  9.         Dim dr2 As Data.DataRow
  10.         Dim sb As New System.Text.StringBuilder
  11.         Dim wr As System.IO.StreamWriter
  12.         Dim var As String = ""
  13.  
  14.         ds = SQLHelperObj.ExecuteDataset(strTrngConn, CommandType.StoredProcedure, "SelectEmployees")
  15.  
  16.         For Each dr In ds.Tables(0).Rows
  17.  
  18.             Response.Write(CStr(dr("EmpNo")))
  19.             Response.Write("<br>")
  20.             Response.Write("<br>")
  21.  
  22.             wr = File.CreateText("C:\" & CStr(dr("EmpNo")) & ".txt")
  23.  
  24.             Dim paramEmpNo As SqlClient.SqlParameter = New SqlClient.SqlParameter("@empno", CType(dr("empNo"), Int32))
  25.  
  26.             ds2 = SQLHelperObj.ExecuteDataset(strTrngConn, CommandType.StoredProcedure, "SelectDocs", paramEmpNo)
  27.  
  28.             For Each dr2 In ds2.Tables(0).Rows
  29.                 sb.Append(var & " " & CStr(dr2("Doc")) & _
  30.                 " " & CStr(dr2("Rev")) & _
  31.                 " " & CStr(dr2("Title")) & _
  32.                 " " & CStr(dr2("InfoCardID")))
  33.                 wr.Write(vbCrLf)
  34.                 wr.WriteLine(sb.ToString)
  35.                 Response.Write(CStr(dr2("Doc")))
  36.                 Response.Write("<br>")
  37.             Next
  38.             wr.Close()
  39.         Next
  40.  
  41.  
Here is my store procedures
Expand|Select|Wrap|Line Numbers
  1.  
  2. CREATE proc SelectEmployees
  3. as
  4.  
  5.   SELECT distinct  tblEmployeeAlerts.EmpNo, tblEmployees.Supervisor 
  6.    FROM       tblEmployeeAlerts
  7.    INNER JOIN tblEmployees
  8.    ON         tblEmployeeAlerts.EmpNo = tblEmployees.EmpNo
  9.    WHERE      tblEmployees.Supervisor = 332
  10.  
  11. return
  12. GO
  13.  
  14. CREATE proc SelectDocs
  15. @EmpNo as int
  16. as
  17.      SELECT distinct dbo.tblCurrentRev.tdc_doc_Num as doc, 
  18.                        dbo.tblCurrentRev.Rev as Rev, 
  19.                        MP_MPI.dbo.tdc_doc_infocard.title_nm as Title, 
  20.                        dbo.tblCurrentRev.InfoCardID
  21.  
  22.        FROM            dbo.tblCurrentRev 
  23.        INNER JOIN      MP_MPI.dbo.tdc_doc_infocard 
  24.        ON              dbo.tblCurrentRev.InfoCardID = MP_MPI.dbo.tdc_doc_infocard.info_card_id
  25.        INNER JOIN      dbo.tblJobDocs 
  26.        ON              dbo.tblCurrentRev.tdc_doc_Num = dbo.tblJobDocs.tdc_Doc_Num 
  27.        INNER JOIN      dbo.tblAssignments 
  28.        ON              dbo.tblJobDocs.JobProfileID = dbo.tblAssignments.ProfileID 
  29.        LEFT OUTER JOIN dbo.tblTrainingRecord 
  30.        ON              dbo.tblAssignments.EmpNo = dbo.tblTrainingRecord.empNo 
  31.        AND             dbo.tblCurrentRev.InfoCardID = dbo.tblTrainingRecord.info_card_id  
  32.  
  33.        WHERE           dbo.tblAssignments.EmpNo = @EmpNo
  34.        AND             dbo.tblTrainingRecord.info_card_id IS NULL
  35.        ORDER BY        tblCurrentRev.tdc_doc_num  
  36. return
  37.  
  38. GO
  39.  
  40.  
Oct 7 '08 #1
0 1259

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Deepa | last post by:
Hi I have a DataSet file (xml) which I need to convert it into a tab delimited file. I need to write a C# console application for doing the same. Can anyone help me out with the code to do it? I'd...
2
by: Keith Chadwick | last post by:
I have a merged dataset that contains xml read from SQL Server. I need to place the data into an XPathDocument. I can do the following: mydataset.writeXML("mydata.xml") dim xpdoc as new...
0
by: Marko Maehner | last post by:
Hi, I have a strange problem with my xml file. In the schema of this xml file I have set one column to autoincrement. When I enter the data in my xml file directly, the autoincrement-column gets...
11
by: scorpion53061 | last post by:
Well I had a way to write an array to an excel spreadsheet but on a huge time critical run it failed iwth the dreaded HRESULT: 0x800A03EC error. It worked fine when i sampled the data to go in but...
6
by: Steven Nagy | last post by:
HI, This all applies to a project in the compact framework (Pocket PC). I need to convert a dataset object into XML which I will then send out via TCP. In a standard app I would do this as...
4
by: Brian Parker | last post by:
Here's a snippet of code I have: ============================================== DataSet ds = new DataSet(); string strXMLFileName = Path.GetTempFileName(); StreamWriter sw = File.AppendText(...
3
by: darrel | last post by:
I'm grabbing an XML string from a database and trying to pass it into a dataset. I've read this article: http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=213 and have tried to implement it as...
4
by: Brad | last post by:
I am trying to convert an XML Stream received from a web api call into a DataSet to use in the rest of the app. The issue I am running into is that it will not convert the stream to a dataset and...
1
by: langthanh | last post by:
hi, i have a dataset and i want to select all the record belong to each empNo and write it to the filename start with that empNo.i can write the file but i don know whay it just write the last...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.