使用vb.net在sqlserver中保存数据 [英] Save data in sqlserver using vb.net

查看:156
本文介绍了使用vb.net在sqlserver中保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个表格

table1是tbl_members

table2是tbl_library

table3是tbl_borrowing



tbl_members hase this columns



idmebmer int autoincrement(主键)

name varchar

adress varchar

tel varchar

email varchar



tbl_library hase this columns

idbook int autoincrement(主键)

bookname varchar

bookauthor varchar

类别varchar



tbl_borrowing hase this columns



idmebmer int autoincrement(primary key)''此列来自tbl_members的外键''



idbook int autoincrement(外键)''这一列是来自tbl_library的外键''



data_checkoutbook varchar''时间用户从库中取出书籍的时间

data_retunbook varchar''的时间用户必须将图书归还图书馆



i cane保存表tbl_library和tbl_members中的数据但

如何保存日期tbl_borrowing为用户如何拿起一本书

用户只能拿一本书来支付



或者我如何构建一个数据库一个图书馆管理系统



对不起我的英文

解决方案

如果用户只能借一本书,那么我很想将贷款细节纳入用户,但是......

当你将列设置为自动增量时你的系统不能工作 - 你不能直接设置那些SQL服务器本身更新的字段 - 任何插入或更新这些值的尝试都会给您一个例外。因为他们想要引用会员和书,你应该从他们那里删除自动增量。



就个人而言,我不喜欢特定的自动增量值item ids - 我更喜欢使用Guids,因为它们可以在创建行时由VB / C#代码设置,而不是由SQL创建,然后必须找到值才能将任何函数应用于它。

i have 3 tablese
table1 is tbl_members
table2 is tbl_library
table3 is tbl_borrowing

tbl_members hase this columns

idmebmer int autoincrement (primary key)
name varchar
adress varchar
tel varchar
email varchar

tbl_library hase this columns
idbook int autoincrement (primary key)
bookname varchar
bookauthor varchar
category varchar

tbl_borrowing hase this columns

idmebmer int autoincrement (primary key) ''this column is from foreign key from tbl_members ''

idbook int autoincrement (foreign key) ''this column is from foreign key from tbl_library''

data_checkoutbook varchar '' the time where the user hase pickup the book from the library
data_retunbook varchar ''the time where the user must return the book to the library

i cane save data in table tbl_library and tbl_members but
how ken i save the date in tbl_borrowing for the user how has pick up a book
the user can only one book pick up

or how to i construk a database for a library menagment system

sorry for my english

解决方案

If the user can only borrow one book, then I would be tempted to incorporate the loan details into the user, but...
Your system won''t work while you have the columns set to autoincrement - you can''t directly set those fields as they are updated by SQL server itself - any attempt to insert or update those values will give you an exception. Since they are suppose to refer to the Member and the Book, You should remove the autoincrement from them.

Personally, I''m not fond of autoincrement values for specific item ids - I prefer to use Guids as they can be set by the VB/C# code when the row is created, rather than created by the SQL and then the value has to be found in order to apply any functions to it.


这篇关于使用vb.net在sqlserver中保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆