如何在FrmAddStudent中显示IDStudent [英] How To show IDStudent In The FrmAddStudent
本文介绍了如何在FrmAddStudent中显示IDStudent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
欢迎我不会有人帮助我的每个人
我正在为学校项目"工作,并为新学生添加信息表格
我需要让用户看到该学生的新ID,
在我的表格中,我有
txtID.text
txtFirstName.text
txtLastName.text
我要进行存储程序
ALTER 过程 AddNewStudent
@ ID int 输出,
@名字 nvarchar ( 10 ),
@姓氏 nvarchar ( 10 ),
插入 INTO 学生
(ID,名字,姓氏)
值( @ ID , @ First , @姓氏)
然后我给学生上课
Dim 构造 As 字符串 = "
Dim 连接 As 新建 SqlConnection(constr)
Dim 命令 As 新建 SqlCommand(" ,连接)
command.CommandType = CommandType.StoredProcedure
connection.Open()
command.Parameters.Add(" ,SqlDbType.Int).Value = ID
command.Parameters.Add(" ,SqlDbType.NVarChar,(" ,SqlDbType.NVarChar,(返回 真实
结束 功能
我想显示内容参数(ID)位于数据库中,而不是将值输入数据库中.
解决方案
已阅读此书,基本上是您需要做的是创建一个参数变量并将其设置为输出参数
输入和输出参数以及返回值 [ ^ ]
>
Welcome every Body I Won''t Someone To Help Me
i''m Work On project For School ,And I make A form For Add Information For A New Student
I need To let User See The New ID For this student ,
In My Form I have
txtID.text
txtFirstName.text
txtLastName.text
And I''m Make a storeprocedure
ALTER PROCEDURE AddNewStudent
@ID int Output,
@FirstName nvarchar(10),
@LastName nvarchar(10),
INSERT INTO Student
(ID,FirstName, LastName)
VALUES (@ID,@FirstName, @LastName)
Then I make A class For Student
Dim constr As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DataBase\DBSchool.mdf;Integrated Security=True;User Instance=True"
Dim connection As New SqlConnection(constr)
Dim command As New SqlCommand("AddNewStudent", connection)
command.CommandType = CommandType.StoredProcedure
connection.Open()
command.Parameters.Add("@ID", SqlDbType.Int).Value = ID
command.Parameters.Add("@FirstName", SqlDbType.NVarChar, (10)).Value = FirstName
command.Parameters.Add("@LastName", SqlDbType.NVarChar, (10)).Value = LastName
Return True
End Function
I want to show content prameter (ID) is located in the database instead of entering the value to the database
解决方案
Have a read of this, basically what you need to do is create a parameter variable and set it up as an output parameter
Input and Output Parameters, and Return Values[^]
这篇关于如何在FrmAddStudent中显示IDStudent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文