小编Ash*_*wal的帖子

当IDENTITY_INSERT设置为OFF时,无法在表'userlogins'中为identity列插入显式值?

我的DBML Designer代码是这样的

[Column(Storage="_id",IsPrimaryKey=true,DbType="Int")]
public System.Nullable<int> id
{
    get
    {
        return this._id;
    }
    set
    {
        if ((this._id != value))
        {
            this._id = value;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

和我的C#代码这个

DataClassesDataContext db = new DataClassesDataContext();
userlogin tc = new userlogin();

tc.username = TextBox1.Text;
tc.pass = TextBox2.Text;
db.userlogins.InsertOnSubmit(tc);
db.SubmitChanges();
Response.Redirect("Main.aspx");
Run Code Online (Sandbox Code Playgroud)

当我在文本框中插入数据错误时,当IDENTITY_INSERT设置为OFF时,无法在表'userlogins'中为标识列插入显式值

c# linq asp.net linq-to-sql

4
推荐指数
1
解决办法
2777
查看次数

dataclassesdatacontext'不包含带0个参数的构造函数?

这是我的DBML Designer代码

    using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;



public partial class DataClassesDataContext  : System.Data.Linq.DataContext 

{

    private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

  #region Extensibility Method Definitions
  partial void OnCreated();
  #endregion

    public DataClassesDataContext(string connection) : 
            base(connection, mappingSource)

    {
        OnCreated();
    }

    public DataClassesDataContext(System.Data.IDbConnection connection) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

    public DataClassesDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
            base(connection, mappingSource)
    {
        OnCreated();
    }

    public DataClassesDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : 
            base(connection, mappingSource)
    { …
Run Code Online (Sandbox Code Playgroud)

c# sql linq asp.net linq-to-sql

0
推荐指数
1
解决办法
6984
查看次数

标签 统计

asp.net ×2

c# ×2

linq ×2

linq-to-sql ×2

sql ×1