I'm starting a new project and decided to use Linq to access the database. It appears to be relatively easy. It didnt take long to get my database output to screen using a GridView. But then I tried to insert new data into the database and failed. I've looked at a number of tutorials and they all say to use "db.members.add(member)". However when I try this the "add" keyword is not appearing for me. I dont know what the problem is. The following is a screen shot of what is happening.

I have also tried using "db.Members.insertonsubmit(member)" followed by "db.submitChanges()". This didnt work either.
The following is the code I've started with. Note: this is just an application I started to practice using to Linq.
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
NisusDataContext db = new NisusDataContext();
Member member = new Member();
member.FirstName = "John";
member.LastName = "Doe";
var getAllTeams = from t in db.Members select t;
GridView1.DataSource = getAllTeams;
GridView1.DataBind();
}
}
}
Any help will be greatly appreciated.
Regards,
Eamon

New Topic/Question
Reply




MultiQuote



|