我一直在使用Scott Gu的LINQ to SQL教程来学习一些LINQ.我已经能够查看,检索和更新记录,但我无法将新记录写入数据库(MSSQL).Scott开始在教程集的第四部分插入行.正如您在该页面上看到的那样(或者可能已经知道),为了添加记录,您必须执行以下操作(VB.NET):
Dim db as New LINQtoSQLDataContext Dim oArticle as New article // table name oArticle.Body = "Some Text" oArticle.Title = "Some Title" oArticle.Author = "Some Author" db.articles.Add(oArticle) // this is the line that does not work.
Visual Studio 2008返回" 'add' is not a member of 'System.Data.Linq.Table(Of article)
".
任何人都可以给我一个正确的方向吗?谢谢!
db.articles.InsertOnSubmit(oArticle) db.SubmitChanges()