2018年1月30日 星期二

純文字檔案(例如:txt,csv)轉成DataTable的方法

純文字檔案(例如:txt,csv)轉成DataTable的方法


Public Function TxtConvertToDataTable(File As String, TableName As String, delimiter As String) As DataTable
Dim dt As New DataTable()
Dim ds As New DataSet()
Dim s As New StreamReader(File, System.Text.Encoding.[Default])
'string ss = s.ReadLine();//skip the first line
Dim columns As String() = s.ReadLine().Split(delimiter.ToCharArray())
ds.Tables.Add(TableName)
For Each col As String In columns
Dim added As Boolean = False
Dim [next] As String = ""
Dim i As Integer = 0
While Not added
Dim columnname As String = col + [next]
columnname = columnname.Replace("#", "")
columnname = columnname.Replace("'", "")
columnname = columnname.Replace("&", "")

If Not ds.Tables(TableName).Columns.Contains(columnname) Then
ds.Tables(TableName).Columns.Add(columnname.ToUpper())
added = True
Else
i += 1
[next] = "_" + i.ToString()
End If
End While
Next

Dim AllData As String = s.ReadToEnd()
Dim rows As String() = AllData.Split(vbLf.ToCharArray())

For Each r As String In rows
Dim items As String() = r.Split(delimiter.ToCharArray())
ds.Tables(TableName).Rows.Add(items)
Next

s.Close()

dt = ds.Tables(0)

Return dt
End Function

2018年1月16日 星期二

Directory.Exists 無法訪問 win10 權限問題

修正  :
HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System



EnableLUA  -->1 ---to 0 [關閉]


這樣程式在訪問 win10 path 就能正常了

2018年1月11日 星期四

Crystal Reports, Developer for Visual Studio 2010-2017

官方下載網址:
Crystal Reports, Developer for Visual Studio Downloads

Copy of Crystal Reports, developer version for Microsoft Visual Studio - Service Pack 22 - Fixed Issues
--
OS 裡面有 2010 , 2015  -- 結果安裝SP21 把 VS2015 工具OK了
現問題來了 , 原 2010 安裝 SP3 版本的;全被幹掉了
完全不能執行了報表了

code 遇到 CrystalDecisions.CrystalReports.Engine.ReportDocument  全部報錯

--
把SP21 移除 ,  重安裝 SP3 for vs2010 ...也是掛了
--
安裝 Crystal Report SP21 記錄:
1. VS2008 因內建Crystal Report , 完全不受影響;可以正常運作!
2. VS2010 掛
3.VS2015 雖裝上了,未測是否執行沒問題
--
待續... (等處理好,續文...)

---------------------------------------------------------------------------------------------------------

20180114 --總算找出問題,底下為解決方法:

*** 安裝順序:VS2008->VS2010->VS2015->CRforVS_13_0_21->CRforVS_redist_install_64bit_13_0_21
因專案有2008/2010/2015 , 所以必須一次安裝完成後;才安裝水晶報表套件

若已安裝舊版本,必須把SP ?? / 執行階段版本(OSx64->預設會安裝64)  ===均移除後,才能安裝新版本的SP
(我不確定移除後再安裝是否有效,因我已砍掉重練了...)


1. 組件
CrystalDecisions.CrystalReports.Engine / 內嵌:False (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.CrystalReports.Engine.dll

CrystalDecisions.Enterprise.Framework / 內嵌:Ture (版本:10.5.3700.0) /特定:Ture  (執行:v1.0.3705)
C:\Windows\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Enterprise.Framework.dll

CrystalDecisions.Enterprise.InfoStore / 內嵌:Ture (版本:10.5.3700.0) /特定:Ture  (執行:v1.0.3705)
C:\Windows\assembly\GAC\CrystalDecisions.Enterprise.InfoStore\10.5.3700.0__692fbea5521e1304\CrystalDecisions.Enterprise.InfoStore.dll

CrystalDecisions.ReportSource / 內嵌:False  (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.ReportSource.dll

CrystalDecisions.Shared / 內嵌:False  (版本:10.5.3700.0) /特定:Ture  (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.Shared.dll

CrystalDecisions.Windows.Forms / 內嵌:False  (版本:10.5.3700.0) /特定:Ture (執行:v2.0.50727)
C:\Program Files (x86)\Business Objects\Common\2.8\managed\CrystalDecisions.Windows.Forms.dll
---
有發現組件竟都是舊版本嗎? (全引用VS2008的組件==>是否因跟不上微軟一直更新產生的問題?全改回基本)
已實測過,VS2008 在任何windows版本上均不會有問題(不管windows怎update)
真的是沒砍掉重練,真的問題永遠不知道在哪...
所以客戶端,必須安裝 CRRedist2008_x86.msi + CRRedist2008_x86_cht.msi
----
***原本的專案組件必須重新參考引用跟上列表一樣的組件***
----
2.執行後,發生錯誤: crystal reports SetDataSource 未知的查詢引擎錯誤

APP.config 加入:

<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>

------
原舊產品 , 若原是安裝 CRforVS_13_0_21(以下)的版本 ; 必須重新引用參考: (不可引用VS2008的組件)
CrystalDecisions.CrystalReports.Engine
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.CrystalReports.Engine.dll

CrystalDecisions.ReportSource
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.ReportSource.dll

CrystalDecisions.Shared
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.Shared.dll

CrystalDecisions.Windows.Forms
C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\CrystalDecisions.Windows.Forms.dll


2018年1月9日 星期二

vs2015 未正確載入套件 Crystal Reports Tools Package



----
實在是...
遇到這問題, 第一時間就是google ..結果通通是亂搞一通"瞎搞"

安裝的是 Crystal Report For VS -SP 21 版的 - 要安裝到VS 2015
結果開工具就冒出這些問題,實在浪費時間

也重開機了,說啥重新啟動就可以OK ; 也把VS 設定重設也沒用

最後一招就是"重新安裝"SP 21 的 crystal report 套件 ; 進VS 總算正常看到了

哈!  今晚的時間也耗掉了...=  . =!!  明天可以正常繼續進度了

注意:
是"重新安裝"  (不是移除後再安裝....[這個我沒試,重安裝就正常了]);希望有相同問題的,試試的我方法吧! 別搞一堆  /setup  / reset xxxx  的指令..浪費時間




2018年1月6日 星期六

在UpdatePanel裡使用FileUpload控制項

參考引用:[ASP.NET]在UpdatePanel裡使用FileUpload控制項
---

 <asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional">
 
    <contenttemplate>
 
        <asp:fileupload id="FileUpload1" runat="server">
 
        <asp:button id="Button1" runat="server" text="Button">
 
    </asp:button></asp:fileupload></contenttemplate>
 
    <triggers>
 
    <asp:postbacktrigger controlid="Button1">
 
    </asp:postbacktrigger></triggers>
 
    </asp:updatepanel>
<div id="BA_AD1" class="Ba_Ad" style="margin: 12px 0 12px 0;"><div id="ba_ad_05371293839500693" class="AdItem Ad_300x250 Float_L Mg_R_1"><div class="AdBox"><ins class="ucfad_async" style="display:inline-block;width:300px;height:250px" data-ad_unit_id="ad-D2333E9DE6B989460D349AD98DE466A4" data-impr="//js1.bloggerads.net/ucFunnelImpression/675286257.RZHoFAia/20081101000220/63650875099/4?Referer=http%3a%2f%2fjiaming0708.pixnet.net%2fblog%2fpost%2f31183423-%5basp.net%5d%25E5%259C%25A8updatepanel%25E8%25A3%25A1%25E4%25BD%25BF%25E7%2594%25A8fileupload%25E6%258E%25A7%25E5%2588%25B6%25E9%25A0%2585" data-ucfad-loaded="done"><div id="ucfadbg_ucfad_NiC2MDmL" style="display: inline-block;"><div id="ucfadimg_ucfad_NiC2MDmL" style="position: relative;"><iframe name="ucfad_NiC2MDmL" id="ucfad_NiC2MDmL" class="ucfad" width="300px" height="250px" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" allowfullscreen="true" style="border: none; overflow: hidden; width: 300px; height: 250px;"></iframe></div></div></ins></div><div class="Tag"><a href="http://www.bloggerads.net" title="BloggerAds 部落格行銷" target="_blank">BloggerAds 部落格行銷</a></div></div><div id="ba_ad_03098541826921881" class="AdItem Ad_300x250 Float_L"><div class="AdBox"><ins class="ucfad_async" style="display:inline-block;width:300px;height:250px" data-ad_unit_id="ad-D2333E9DE6B989460D349AD98DE466A4" data-impr="//js1.bloggerads.net/ucFunnelImpression/675286257.RZHoFAia/20081101000220/63650875099/4?Referer=http%3a%2f%2fjiaming0708.pixnet.net%2fblog%2fpost%2f31183423-%5basp.net%5d%25E5%259C%25A8updatepanel%25E8%25A3%25A1%25E4%25BD%25BF%25E7%2594%25A8fileupload%25E6%258E%25A7%25E5%2588%25B6%25E9%25A0%2585" data-ucfad-loaded="done"><div id="ucfadbg_ucfad_ihNLxHTM" style="display: inline-block;"><div id="ucfadimg_ucfad_ihNLxHTM" style="position: relative;"><iframe name="ucfad_ihNLxHTM" id="ucfad_ihNLxHTM" class="ucfad" width="300px" height="250px" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" allowfullscreen="true" style="border: none; overflow: hidden; width: 300px; height: 250px;"></iframe></div></div></ins></div><div class="Tag"><a href="http://www.bloggerads.net" title="BloggerAds 部落格行銷" target="_blank">BloggerAds 部落格行銷</a></div></div></div>

2018年1月5日 星期五

無法連接到設定的程式開發 Web 伺服器 (vs2015)

vs2015 最近更新後,又開始出現:無法連接到設定的程式開發 Web 伺服器
查看很多細節設定都偷偷修改過
以前 只要刪 .vs 目錄再重新啟動 vs2015 就可正常
現在已不是單純刪 .vs 即可
現作法須:
1.重開機
2.刪 .vs 目錄
3.開啟你的方案