小编Yas*_*iya的帖子

SQL:从SELECT语句返回的所有条目中删除部分字符串

以下是select语句,它返回包含%20(空格)的所有URL :

select * from Table1 where Column1 like '%%20'
Run Code Online (Sandbox Code Playgroud)

如何使用SQL从所有这些URL中删除' %20 '?

编辑1:

有没有办法删除' %20 '只有在URL的末尾找到它(保存URL中' %20 '的所有其他实例)?

sql t-sql string replace sql-server-2012

9
推荐指数
2
解决办法
2310
查看次数

使用 C# 从 Windows 窗体应用程序上的 CSV 文件读取和显示数据

我编写了以下用于从 .csv 文件读取数据的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace CSVRead
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void buttonRead_Click(object sender, EventArgs e)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("Username");
            dataTable.Columns.Add("Password");
            dataTable.Columns.Add("MachineID");
            string filePath = textBox1.Text;
            StreamReader streamReader = new StreamReader(filePath);
            string[] totalData = new string[File.ReadAllLines(filePath).Length];
            totalData = streamReader.ReadLine().Split(',');
            while (!streamReader.EndOfStream)
            {
                totalData = streamReader.ReadLine().Split(',');
                dataTable.Rows.Add(totalData[0], totalData[1], totalData[2]);
            } …
Run Code Online (Sandbox Code Playgroud)

c# csv datagridview winforms

3
推荐指数
1
解决办法
3万
查看次数

使用 C# 从控制台应用程序访问 HTTPS URL

我希望我的应用程序访问指定的 HTTPS URL 并从该 URL 下载 CSV 文件。

我有以下代码:

程序.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Security;
using System.IO;

namespace httpWebRequest_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var webAddr = "https://SFTP URL/xyz.csv";
            var httpWebRequest = (HttpWebRequest) WebRequest.Create(webAddr);
            httpWebRequest.ContentType = "text/csv";
            httpWebRequest.Method = "POST";
            var httpResponse = (HttpWebResponse) httpWebRequest.GetResponse();
            //ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
            Stream resStream = httpResponse.GetResponseStream();
        }

        AcceptAllCertification aac = new AcceptAllCertification();

        public static RemoteCertificateValidationCallback …
Run Code Online (Sandbox Code Playgroud)

c# url ssl https

2
推荐指数
1
解决办法
5621
查看次数

C#错误:上下文关键字'var'可能只出现在局部变量声明中

我编写了以下函数来创建axWindowsMediaPlayer播放列表:

WMPLib.IWMPPlaylist p2 = axWindowsMediaPlayer.playlistCollection.newPlaylist("Playlist 1");

private void CreatePlaylist(string _currentId)
{
  string selectedElementPageTypeValue = MainContentAreaBl.GetSelectedElementPageTypeValue(_currentId);
  var selectedElementJumpToValue = MainContentAreaBl.GetSelectedElementValue(_currentId, "jumpTo");
  if (selectedElementJumpToValue != null)
  {
     _currentId = selectedElementJumpToValue;                
     if (_currentId != null && _currentId != "menu" && selectedElementPageTypeValue == "video")
     {
        var playerFile = Path.Combine(Common.ContentFolderPath, MainContentAreaBl.GetSelectedElementDataPathValue(_currentId));
        p2.appendItem(axWindowsMediaPlayer.newMedia(playerFile));
        axWindowsMediaPlayer.currentPlaylist = p2;
        CreatePlaylist(_currentId);
     }                
     axWindowsMediaPlayer.Ctlcontrols.play();
  }
}
Run Code Online (Sandbox Code Playgroud)

var p2是在班级宣布的.当我编译我的应用程序时,我收到以下错误消息:

上下文关键字'var'可能只出现在局部变量声明中

但是,我不能放入var p2 = axWindowsMediaPlayer.playlistCollection.newPlaylist("Playlist 1");递归函数,因为它会在每次迭代时创建新的播放列表.

如何在我的函数中访问p2?

编辑1:我在输出窗口中看到了这一点

COM参考'WMPLib'是ActiveX控件'AxWMPLib'的互操作程序集,但标记为由编译器与/ link标志链接.此COM引用将被视为参考,不会链接.

此外,现在它显示以下错误axWindowsMediaplayer:

字段初始值设定项不能引用非静态字段,方法或属性

这些信息是否与我所看到的错误有关?怎么去解决这个问题?

c# var compiler-errors winforms

0
推荐指数
1
解决办法
5268
查看次数

标签 统计

c# ×3

winforms ×2

compiler-errors ×1

csv ×1

datagridview ×1

https ×1

replace ×1

sql ×1

sql-server-2012 ×1

ssl ×1

string ×1

t-sql ×1

url ×1

var ×1