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

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 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格