hi,
following is the code for save to database using linq
DataContext Db = new DataContext("Data Source=baiju-pc;Initial Catalog=Baiju;Integrated Security=True");
string msg = string.Empty;
customer objCustomer = new customer();
objCustomer.Id = Convert.ToInt32(TextBox1.Text.ToString());
objCustomer.name = TextBox2.Text;
objCustomer.address = TextBox3.Text;
try
{
Db.GetTable<customer>().InsertOnSubmit(objCustomer);
Db.SubmitChanges();
Label1.Text = "Inserted successfully";
}
catch (Exception ex)
{
msg = ex.Message;
Label1.Text = msg;
}
finally
{
Db.Dispose();
}
***************************************
[Table (Name="customer")]
public class customer
{
[Column (DbType="int",IsPrimaryKey=true)]
public int Id
{ get; set; }
[Column (DbType="nvarchar(50)")]
public string name
{ get; set; }
[Column (DbType="nvarchar(50")]
public string address
{ get; set; }
}
but error is showing
this is the error
Length cannot be less than zero.
Parameter name: length
what is the reason
Regards
Baiju