太阳是更年期 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 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler