4
我一直在利用Scott Gu's tutorials on LINQ to SQL来试图学习一些LINQ。我已经能够查看,检索和更新记录,但我无法将新记录写入数据库(MSSQL)。 Scott开始插入教程集的fourth section中的行。正如你可以在页面上看到(或者可能已经知道了),为了增加你必须做到以下几点(VB.NET)的纪录:如何使用LINQ将记录添加到数据库?
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) – andleer 2009-03-02 13:51:03