VB ASP.NET 检查数据是否在表中,如果是,则更新,否则插入
我浏览了整个互联网(嗯,感觉就是这样)来找到这个问题。
表 - 作者和标题
添加新标题必须链接到作者,因此我需要检查作者是否存在,如果存在,则使用文本框中的用户数据更新标题表。如果作者不存在,我需要先插入作者&将姓氏放入作者表中,然后将标题信息放入标题表中。
这是用 VB 编写的,使用 ASP.NET,我的数据库是一个文件,我没有使用 SQL Server,只是使用 Visual Studio 2008。
提前非常感谢您的指导
Dim insertParameters As New ListDictionary()
insertParameters.Add("ISBN", ISBNTextBox.Text)
insertParameters.Add("Title", titleTextBox.Text)
insertParameters.Add("EditionNumber", editionNumberTextBox.Text)
insertParameters.Add("Copyright", copyrightTextBox.Text)
insertParameters.Add("FirstName", firstTB.Text)
insertParameters.Add("Surname", secondTB.Text)
LinqDataSource1.Insert(insertParameters)
I have looked through the entire internet (well that's what it feels like) to find this out.
Tables - Authors and Titles
add new title must be linked to an author, so I need to check that the author exists, if so, update the titles table with the user data from the textboxes. If the author does not exist, I need to insert the author first & last name into the author table, then the title info into the title table.
this is in VB, using ASP.NET, and my database is a file, I'm not using SQL server, just Visual Studio 2008.
Many thanks in advance for any guidance
Dim insertParameters As New ListDictionary()
insertParameters.Add("ISBN", ISBNTextBox.Text)
insertParameters.Add("Title", titleTextBox.Text)
insertParameters.Add("EditionNumber", editionNumberTextBox.Text)
insertParameters.Add("Copyright", copyrightTextBox.Text)
insertParameters.Add("FirstName", firstTB.Text)
insertParameters.Add("Surname", secondTB.Text)
LinqDataSource1.Insert(insertParameters)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,你应该退后一步才能了解大局。下面是一个视频链接,可帮助您开始使用 LinqToSQL http://www.linqtosql.com。 youtube.com/watch?v=zy4Y34brSC8&feature=lated。我这么说的原因是,你似乎可能忽略了基本原理,并试图本末倒置。这是 MS 文档的链接,我相信从长远来看,它应该真正帮助您 http://msdn.microsoft.com/en-us/library/bb386976%28v=VS.90%29.aspx
It sounds to me like you should take a step back to get the big picture. Here is a link to a video to get you started on LinqToSQL http://www.youtube.com/watch?v=zy4Y34brSC8&feature=related. The reason I say that is it appears as though you might be missing the fundamentals and trying to put the cart before the horse so to speak. And here is a link to the MS documentation which I believe should really help you in the long run http://msdn.microsoft.com/en-us/library/bb386976%28v=VS.90%29.aspx