我使用C#插入数据以访问2000-2003文件格式数据库.当我有一个包含2个字段的数据库时,查询工作正常,但是当有更多字段时,它不起作用.
我有两个相同的代码,我无法找到问题.
using System.Data.OleDb; // By using this namespace I can connect to the Access Database.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private OleDbConnection myconn;
public Form1()
{
InitializeComponent();
myconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\leelakrishnan\Desktop\NewManageContacts.mdb");
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'newManageContactsDataSet.Contacts' table. You can move, or remove it, as needed.
// this.contactsTableAdapter.Fill(this.newManageContactsDataSet.Contacts);
// TODO: This line of code loads data into the 'newManageContactsDataSet.Contacts' table. …Run Code Online (Sandbox Code Playgroud) 这是我从给定字符串中查找最大单词的代码.我已经得到了字符串中所有单词的长度,现在如何获得要打印出来的最大单词?我试图获得所有最大的单词,但我无法使用此代码PLZ帮助?
using System;
using System.Linq;
class largest1{
public void largest(){
Console.WriteLine("Enter the String:");
string buffer1 = Console.ReadLine();
string[] buffer = buffer1.Split(' ');
int length;
string largestword = buffer[0];
for(int i = 0; i < buffer.Length; i++){
string temp = buffer[i];
length = temp.Length;
if( largestword.Length < buffer[i].Length ) {
largestword = buffer[i];
}
}
var largestwords = from words in buffer
let x = largestword.Length
where words.Length == x
select words;
Console.Write("Largest words are:");
foreach(string s in largestwords){
Console.Write(s);
} …Run Code Online (Sandbox Code Playgroud) 我从用户那里得到一个字符串,然后把它放在一个char数组中.现在我想显示字符串中的所有字符以及它们出现的次数.我的代码如下请纠正我?
using System;
class count
{
public void charcount()
{
int i ;
int count = 0;
string s;
Console.WriteLine("Enter the String:");
s = Console.ReadLine();
char[] carr = s.ToCharArray();
for(i = 0; i < carr.Length; i++)
{
for(int j = 1; j < carr.Length; j++)
{
if(carr[j] == carr[i])
{
count++;
}
else
{
return;
}
Console.WriteLine("The Character " + carr[i] + " appears " + count);
}
}
}
static void Main()
{
count obj = new count();
obj.charcount(); …Run Code Online (Sandbox Code Playgroud)