tjpal
asked on
CSV QUestion in VB.net
I could really use some help with this code here. I have code that I was thought to only export 1 line with header than later found out that I need a number of them.
The text coming in is less than cleaned up and I was able to do 1 line and strip all the characters out.
I am having a problem just getting it to loop through x amount of lines.
''Dim filePathcopy As String = Server.MapPath("hcfilesbk/ Post" & "-" & DateTime.Now.ToString("MM- dd-yy-HH-m m") & ".csv")
''Dim delimiterCopy As String = ","
''Dim TheJobDescriptioncopy As String
''TheJobDescriptioncopy = (Replace(JobDescription.Te xt, "•", "<li>"))
''TheJobDescriptioncopy = (Replace(JobDescription.Te xt, "•", "<li>"))
''TheJobDescriptioncopy = (Replace(JobDescription.Te xt, "’", """))
''TheJobDescriptioncopy = (Replace(JobDescription.Te xt, vbCrLf, ""))
''Dim TheBenefitsRequirementscop y As String
''TheBenefitsRequirementsc opy = (Replace(BenefitsRequireme nts.Text, "•", "<li>"))
''TheBenefitsRequirementsc opy = (Replace(BenefitsRequireme nts.Text, "•", "<li>"))
''TheBenefitsRequirementsc opy = (Replace(BenefitsRequireme nts.Text, "’", """))
''TheBenefitsRequirementsc opy = (Replace(BenefitsRequireme nts.Text, vbCrLf, ""))
''Dim TheCompanyOverviewcopy As String
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T ext, "•", "<li>"))
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T ext, "•", "<li>"))
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T ext, "’", """))
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T ext, vbCrLf, ""))
''Dim outputcopy As String()() = New String()() _
''{New String() {"SR_ID", "SR_Name", "SR_Name_Show", "SR_Address", "SR_City", "SR_State", "SR_zip", "SR_Phone", "SR_Phone_Show", "SR_Fax", "SR_Fax_Show", "SR_Email", "SR_JobID", "SR_OpeningsID", "SR_JobTitle", "JobTypeCode", "SR_MCA_Other_Text", "SR_SalaryRangeBase", "SR_SalaryRangeHigh", "SR_LocName", "SR_City1", "SR_State1", "SR_Zip1", "SR_PosReqs", "PositionSummary", "SR_Date", "SR_Discipline_ID", "SR_Job_Status"}, _
'' New String() {(Request.QueryString("ID" )), (Replace(FullName.Text, ",", ",")), _
'' (SR_Name_Show.Text), (Replace(SR_Address.Text, ",", ",")), (Replace(SR_City.Text, ",", ",")), _
'' (selStateCode.Text), (SR_Zip.Text), (Replace(SR_Phone.Text, ",", ",")), (SR_Phone_Show.Text), _
'' (Replace(SR_Fax.Text, ",", ",")), (SR_Fax_Show.Text), (Replace(email.Text, ",", ",")), _
'' (SR_JobID.Text), (Replace(PrimaryIndustry.T ext, ",", ",")), (Replace(JobTitle.Text, ",", ",")), _
'' (JobTypeCode.Text), (Replace(TheCompanyOvervie w, ",", ",")), (Replace(BasePayL.Text, ",", ",")), _
'' (Replace(BasePayH.Text, ",", ",")), (Country.Text), (Replace(City.Text, ",", ",")), (State.Text), _
'' (Replace(USZip5.Text, ",", ",")), (Replace(TheBenefitsRequir ements, ",", ",")), _
'' (Replace(TheJobDescription , ",", ",")), (Replace(SR_Date.Text, ",", ",")), _
'' (SR_Job_Status.Text)}}
''Dim lengthc As Integer = outputcopy.GetLength(0)
''Dim sbc As New StringBuilder()
''For index As Integer = 0 To length - 1
'' sbc.AppendLine(String.Join (delimiter Copy, outputcopy(index)))
''Next
''File.WriteAllText(filePa thcopy, sbc.ToString())
'objCmd = New System.Data.OleDb.OleDbCom mand()
'With objCmd
' .Connection = objConn
' .CommandType = CommandType.Text
' .CommandText = strSQL
'End With
'objCmd.ExecuteNonQuery()
'Next
The text coming in is less than cleaned up and I was able to do 1 line and strip all the characters out.
I am having a problem just getting it to loop through x amount of lines.
''Dim filePathcopy As String = Server.MapPath("hcfilesbk/
''Dim delimiterCopy As String = ","
''Dim TheJobDescriptioncopy As String
''TheJobDescriptioncopy = (Replace(JobDescription.Te
''TheJobDescriptioncopy = (Replace(JobDescription.Te
''TheJobDescriptioncopy = (Replace(JobDescription.Te
''TheJobDescriptioncopy = (Replace(JobDescription.Te
''Dim TheBenefitsRequirementscop
''TheBenefitsRequirementsc
''TheBenefitsRequirementsc
''TheBenefitsRequirementsc
''TheBenefitsRequirementsc
''Dim TheCompanyOverviewcopy As String
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T
''TheCompanyOverviewcopy = (Replace(CompanyOverview.T
''Dim outputcopy As String()() = New String()() _
''{New String() {"SR_ID", "SR_Name", "SR_Name_Show", "SR_Address", "SR_City", "SR_State", "SR_zip", "SR_Phone", "SR_Phone_Show", "SR_Fax", "SR_Fax_Show", "SR_Email", "SR_JobID", "SR_OpeningsID", "SR_JobTitle", "JobTypeCode", "SR_MCA_Other_Text", "SR_SalaryRangeBase", "SR_SalaryRangeHigh", "SR_LocName", "SR_City1", "SR_State1", "SR_Zip1", "SR_PosReqs", "PositionSummary", "SR_Date", "SR_Discipline_ID", "SR_Job_Status"}, _
'' New String() {(Request.QueryString("ID"
'' (SR_Name_Show.Text), (Replace(SR_Address.Text, ",", ",")), (Replace(SR_City.Text, ",", ",")), _
'' (selStateCode.Text), (SR_Zip.Text), (Replace(SR_Phone.Text, ",", ",")), (SR_Phone_Show.Text), _
'' (Replace(SR_Fax.Text, ",", ",")), (SR_Fax_Show.Text), (Replace(email.Text, ",", ",")), _
'' (SR_JobID.Text), (Replace(PrimaryIndustry.T
'' (JobTypeCode.Text), (Replace(TheCompanyOvervie
'' (Replace(BasePayH.Text, ",", ",")), (Country.Text), (Replace(City.Text, ",", ",")), (State.Text), _
'' (Replace(USZip5.Text, ",", ",")), (Replace(TheBenefitsRequir
'' (Replace(TheJobDescription
'' (SR_Job_Status.Text)}}
''Dim lengthc As Integer = outputcopy.GetLength(0)
''Dim sbc As New StringBuilder()
''For index As Integer = 0 To length - 1
'' sbc.AppendLine(String.Join
''Next
''File.WriteAllText(filePa
'objCmd = New System.Data.OleDb.OleDbCom
'With objCmd
' .Connection = objConn
' .CommandType = CommandType.Text
' .CommandText = strSQL
'End With
'objCmd.ExecuteNonQuery()
'Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I was hoping to use what I had and though I was just missing a loop around it. I'm only gfetting 1 row and the header. I'd like to keep the header and loop my rows, but this is very helpful
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
ASKER
I'm just trying to get it to loop all records and not loop the header I resear I have researched many ways of exporting, but this was the only way I could find to get the result I needed.
output = New String()() _
'{New String() {"SR_ID", "SR_Name", "SR_Name_Show", "SR_Address", "SR_City", "SR_State", "SR_zip", "SR_Phone", "SR_Phone_Show", "SR_Fax", "SR_Fax_Show", "SR_Email", "SR_JobID", "SR_OpeningsID", "SR_JobTitle", "JobTypeCode", "SR_MCA_Other_Text", "SR_SalaryRangeBase", "SR_SalaryRangeHigh", "SR_LocName", "SR_City1", "SR_State1", "SR_Zip1", "SR_PosReqs", "PositionSummary", "SR_Date", "SR_Job_Status"}, _
' New String() {(Request.QueryString("ID"
' (SR_Name_Show.Text), (Replace(SR_Address.Text, ",", ",")), (Replace(SR_City.Text, ",", ",")), _
' (selStateCode.Text), (SR_Zip.Text), (Replace(SR_Phone.Text, ",", ",")), (SR_Phone_Show.Text), _
' (Replace(SR_Fax.Text, ",", ",")), (SR_Fax_Show.Text), (Replace(email.Text, ",", ",")), _
' (SR_JobID.Text), (Replace(PrimaryIndustry.T
' (JobTypeCode.Text), (Replace(TheCompanyOvervie
' (Replace(BasePayH.Text, ",", ",")), (Country.Text), (Replace(City.Text, ",", ",")), (State.Text), _
' (Replace(USZip5.Text, ",", ",")), (Replace(TheBenefitsRequir
' (Replace(TheJobDescription
' (SR_Job_Status.Text)}}
''(Replace(longtext, ",", ",", "'", "'"))
'Dim length As Integer = output.GetLength(0)
'Dim sb As New StringBuilder()
'For index As Integer = 0 To length - 1
' sb.AppendLine(String.Join(
'Next
'File.WriteAllText(thefile