linq 错

 

  

无法将类型为“System.Linq.OrderedEnumerable`2[ BuildingNumber,System.String]”的对象强制转换为类型“System.Collections.Generic.List`1[BuildingNumber]”。
 
 
List<BuildingNumber> query =(List< BuildingNumber>)from BuildingNumber BNName in buildingNumber 
orderby BNName.BNName ascending 
select BNName;


13:32
var query =from BNName in buildingNumber.AsEnumerable<BuildingNumber>() 
orderby BNName.BNName ascending 
select BNName;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是修改后的代码: 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; namespace WindowsFormsApp1_ZQA { public partial class Form3 : Form { public Form3() { InitializeComponent(); } //添加学生信息 private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "") { MessageBox.Show("请填写完整信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string sql = "insert into Student values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','123456')"; DBHelper dB = new DBHelper(); int i = dB.Execute(sql); if (i > 0) { MessageBox.Show("添加学生信息成功"); } else { MessageBox.Show("添加学生信息失败,请检查输入信息"); } } } } } 主要修改内容如下: 1. 在判断输入是否为空的语句中,将“==null”修改为“==""”。 2. 在插入SQL语句中,将“'.'”修改为“','”。 3. 在添加学生信息成功的提示中,将提示语修改为“添加学生信息成功”。 4. 添加失败的提示中,将提示语修改为“添加学生信息失败,请检查输入信息”。 这些修改可以帮助您更好地完成添加学生信息的功能,同时也可以提高程序的健壮性和可靠性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值