太阳是更年期 2017-07-07 12:55 采纳率: 100%
浏览 1061
已采纳

C#,WPF 中linq to sql插入数据出错

类文件如下:
public partial class coursefm : INotifyPropertyChanging, INotifyPropertyChanged
{

private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);

private string _cID;

private string _cName;

    #region 可扩展性方法定义
    partial void OnLoaded();
    partial void OnValidate(System.Data.Linq.ChangeAction action);
    partial void OnCreated();
    partial void OncIDChanging(string value);
    partial void OncIDChanged();
    partial void OncNameChanging(string value);
    partial void OncNameChanged();
    #endregion

public coursefm()
{
OnCreated();
}

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_cID", DbType="NChar(10) NOT NULL", CanBeNull=false, IsPrimaryKey=true)]
public string cID
{
get
{
return this._cID;
}
set
{
if ((this._cID != value))
{
this.OncIDChanging(value);
this.SendPropertyChanging();
this._cID = value;
this.SendPropertyChanged("cID");
this.OncIDChanged();
}
}
}

[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_cName", DbType="VarChar(50) NOT NULL", CanBeNull=false)]
public string cName
{
get
{
return this._cName;
}
set
{
if ((this._cName != value))
{
this.OncNameChanging(value);
this.SendPropertyChanging();
this._cName = value;
this.SendPropertyChanged("cName");
this.OncNameChanged();
}
}
}

出错代码如下
 private void button2_Click(object sender, RoutedEventArgs e)
        {
            t1 = courseIDbox.Text;
            t2 = courseNamebox.Text;
            coursefm csf = new coursefm
            {
                cID = t1;
                cName = t2;
            }
        }

报错如下
严重性 代码 说明 项目 文件 行
错误 CS1513 应输入 } WpfApplication1 E:\study\FINALWORK\WpfApplication1\WpfApplication1\Window1.xaml.cs 38
错误 CS1022 应输入类型、命名空间定义或文件尾 WpfApplication1 E:\study\FINALWORK\WpfApplication1\WpfApplication1\Window1.xaml.cs 43

  • 写回答

1条回答

  • threenewbee 2017-07-07 15:54
    关注

    coursefm csf = new coursefm
    {
    cID = t1, //这里逗号
    cName = t2
    }; //少一个分号

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?