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 record belong to that empNo instead of write all records belong to each empNo. does anybody can help me out ?
here my code: -
objDataset = SQLHelperObj.ExecuteDataset(strTrngConn, CommandType.StoredProcedure, "Test")
-
-
Dim i As Integer
-
-
Dim var As String = ""
-
-
For i = 0 To objDataset.Tables(0).Rows.Count - 1
-
var = CStr(objDataset.Tables(0).Rows(i).Item("EmpNo"))
-
Dim sw As StreamWriter = New StreamWriter("C:\\Inetpub\\wwwroot\\Training\\Training\\Attachments\\" & CStr(objDataset.Tables(0).Rows(i).Item("EmpNo")) & ".txt")
-
sw.WriteLine(CStr(objDataset.Tables(0).Rows(i).Item("Doc")) & " " & CStr(objDataset.Tables(0).Rows(i).Item("Rev")) & " " & CStr(objDataset.Tables(0).Rows(i).Item("Title")))
-
sw.WriteLine(sw.NewLine)
-
sw.Close()
-
-
Dim fileName As String = (CStr(objDataset.Tables(0).Rows(i).Item("EmpNo")) & ".txt")
-
Dim physicalPath As String = ("C:\\Inetpub\\wwwroot\\Training\\Training\\Attachments\\" + fileName)
-
-
Me.Response.WriteFile(physicalPath)
-
-
'strBody = strBody & vbTab & CStr(objRow("Doc")) & Space(10 - CStr(objRow("Doc")).Length) & CStr(objRow("Rev")) & Space(5 - CStr(objRow("Rev")).Length) & CStr(objRow("title")) & vbCrLf
-
'strBody = "Different EmpNo"
-
Next
-
Here is my store proc: -
CREATE proc Test
-
as
-
DECLARE @EmpNo INT,
-
@Supervisor int,
-
@Doc VARCHAR(30),
-
@Rev VARCHAR(10),
-
@Title varchar(255),
-
@InfoCardID varchar (18),
-
@Info_Card_ID varchar(255)
-
-
DECLARE @Result TABLE (EmpNo INT, Doc VARCHAR(50), Rev varchar(255), Title varchar(255))
-
-
DECLARE supervisor_cursor CURSOR
-
FOR
-
SELECT tblEmployeeAlerts.EmpNo, tblEmployees.Supervisor
-
FROM tblEmployeeAlerts
-
INNER JOIN tblEmployees
-
ON tblEmployeeAlerts.EmpNo = tblEmployees.EmpNo
-
WHERE tblEmployees.Supervisor = 332
-
-
OPEN supervisor_cursor
-
FETCH NEXT FROM supervisor_cursor INTO @EmpNo, @Supervisor
-
PRINT 'OUTER LOOP START'
-
-
WHILE (@@FETCH_STATUS = 0)
-
BEGIN
-
SET @Doc = ''
-
DECLARE curDetailList CURSOR
-
FOR
-
SELECT distinct dbo.tblCurrentRev.tdc_doc_Num as doc,
-
dbo.tblCurrentRev.Rev as Rev,
-
MP_MPI.dbo.tdc_doc_infocard.title_nm as Title,
-
dbo.tblCurrentRev.InfoCardID,
-
dbo.tblTrainingRecord.info_card_id
-
FROM dbo.tblCurrentRev
-
INNER JOIN MP_MPI.dbo.tdc_doc_infocard
-
ON dbo.tblCurrentRev.InfoCardID = MP_MPI.dbo.tdc_doc_infocard.info_card_id
-
INNER JOIN dbo.tblJobDocs
-
ON dbo.tblCurrentRev.tdc_doc_Num = dbo.tblJobDocs.tdc_Doc_Num
-
INNER JOIN dbo.tblAssignments
-
ON dbo.tblJobDocs.JobProfileID = dbo.tblAssignments.ProfileID
-
LEFT OUTER JOIN dbo.tblTrainingRecord
-
ON dbo.tblAssignments.EmpNo = dbo.tblTrainingRecord.empNo
-
AND dbo.tblCurrentRev.InfoCardID = dbo.tblTrainingRecord.info_card_id
-
-
WHERE dbo.tblAssignments.EmpNo = @EmpNo
-
AND dbo.tblTrainingRecord.info_card_id IS NULL
-
ORDER BY tblCurrentRev.tdc_doc_num
-
-
OPEN curDetailList
-
FETCH NEXT FROM curDetailList INTO @Doc, @Rev, @Title, @InfoCardID, @Info_Card_ID
-
-
PRINT 'INNER LOOP START'
-
WHILE (@@FETCH_STATUS = 0)
-
BEGIN
-
INSERT INTO @Result VALUES (@EmpNo, @Doc, @Rev, @Title)
-
FETCH NEXT FROM curDetailList INTO @Doc, @Rev, @Title, @InfoCardID, @Info_Card_ID
-
PRINT 'INNER LOOP'
-
END
-
CLOSE curDetailList
-
DEALLOCATE curDetailList
-
-
FETCH NEXT FROM supervisor_cursor INTO @EmpNo, @Supervisor
-
-
PRINT 'OUTER LOOP'
-
END
-
-
CLOSE supervisor_cursor
-
DEALLOCATE supervisor_cursor
-
-
-
-- Publish result
-
-
SELECT * FROM @Result
-
return
-
1 915
Hi langthanh,
Welcome to Bytes.com! I hope you find the site useful.
You've posted your question in the ASP Forum which is for Classic ASP only - I've moved it for you but in future please post all ASP.NET questions in the .NET Forum.
Please don't forget to wrap your code in CODE tags - it makes your posts much easier to read - and please read the Posting Guidelines if you have not done so already.
Thanks and I hope somebody can help you with your problem.
Dr B
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
by: Wayne Wengert |
last post by:
I am attempting to generate an XML file based on the contents of a dataset
which contains a parent-child relationship but when I create the output file
all I get is the XML header as shown here:
...
|
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...
|
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...
|
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(...
|
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...
|
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...
|
by: langthanh |
last post by:
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
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...
| |