Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将访问Oledb转换为C windows窗体阵列_C#_Arrays_Oledb - Fatal编程技术网

C# 如何将访问Oledb转换为C windows窗体阵列

C# 如何将访问Oledb转换为C windows窗体阵列,c#,arrays,oledb,C#,Arrays,Oledb,嗨,有人能帮我吗。 我正在做一个刽子手计划。 但是单词应该来自访问oledb。 谁能告诉我怎么做。 我使用的是Office2007和VS2010 要替换此代码,请执行以下操作: public void text() { char[] divider = {','}; string[] word = {"GENES","APPLES","GRAPES"}; //Words List replace this with words from access

嗨,有人能帮我吗。 我正在做一个刽子手计划。 但是单词应该来自访问oledb。 谁能告诉我怎么做。 我使用的是Office2007和VS2010

要替换此代码,请执行以下操作:

public void text()
    {
        char[] divider = {','};
        string[] word = {"GENES","APPLES","GRAPES"}; //Words List replace    this with words from access oledb//
        words = new string[word.Length]; 
        int counter = 0;
        foreach (string a in word)
        {
                string [] splitter = a.Split(divider);
                words[counter++] = splitter[0]; 
        }

    }

您使用Office 2007的目的是什么?您是否搜索过access oledb CSorry的get记录?为此,我还想问,当值为int而不是string时,如何执行int?@Mary List myInts=new List;然后在while循环中从读卡器读取值,将其转换为int,如while oReader.read myInts.AddConvert.ToInt32oReader.GetValue0;
public void text()
{
     List<string> oWords =  new List<string>();
     string sConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data source=PathtoYourAccessDB.accdb";
     string sQueryString=  "select YourWordsColumn from YouAccessTable";

     using (OleDbConnection oConnection = new OleDbConnection(sConnectionString))
     {
          OleDbCommand oCommand = new OleDbCommand(sQueryString, oConnection);
          oConnection.Open();
          using (OleDbDataReader oReader = oCommand.ExecuteReader())
          {
               while (oReader.Read())
                     oWords.Add(oReader.GetValue(0).ToString());
          }
     }
     // If you want the words in an array
     string [] words = oWords.ToArray();
}