太阳是更年期 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
    }; //少一个分号

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!