C# 如何将访问Oledb转换为C windows窗体阵列
嗨,有人能帮我吗。 我正在做一个刽子手计划。 但是单词应该来自访问oledb。 谁能告诉我怎么做。 我使用的是Office2007和VS2010 要替换此代码,请执行以下操作: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
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();
}