等待用户输入,然后odbcdatareader再次读取

编程入门 行业动态 更新时间:2024-10-27 06:24:43
本文介绍了等待用户输入,然后odbcdatareader再次读取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我这里有一个将从数据库读取的代码块,我要的是让第一个odbcdatareader在可以再次读取数据库之前等待新用户输入.我该怎么做呢?在此先感谢您的帮助..

i have a code block here that will read from a database, what i want is for the first odbcdatareader to wait for a new user input before it could read again the database.. how may i do this exactly? thanks in advance for any help..

<br /> <pre lang="vb">Public Sub find_studs()<br /> Dim connection As New OdbcConnection<br /> Dim dr As OdbcDataReader<br /> Dim command As OdbcCommand<br /> Try<br /> '' Open Connection<br /> connection = New OdbcConnection(ConnStr)<br /> connection.Open()<br /> command = New OdbcCommand("select * from schedule where sched_code = ''" & TextBox1.Text & "''", connection)<br /> dr = command.ExecuteReader()<br /> Dim flag As Boolean = False<br /> While (dr.Read())<br /> flag = True<br /> dr.Close()<br /> connection.Close()<br /> connection = New OdbcConnection(ConnStr)<br /> connection.Open()<br /> command = New OdbcCommand("select * from student_history where crs_name = ''" & dr(1).ToString & "'' and s_year = ''" & dr(2).ToString & "'' and block = ''" & dr(3).ToString & "''", connection)<br /> dr = command.ExecuteReader()<br /> studnum.Text = dr(0).ToString<br /> <br /> dr.Close()<br /> connection.Close()<br /> connection = New OdbcConnection(ConnStr)<br /> connection.Open()<br /> command = New OdbcCommand("select * from student where stud_num = ''" & studnum.Text & "''", connection)<br /> dr = command.ExecuteReader()<br /> studname.Text = dr(1).ToString & ", " & dr(2).ToString & " " & dr(3).ToString<br /> <br /> btn_next.Enabled = True<br /> GoTo skippy<br /> End While<br /> skippy: If flag = False Then<br /> MsgBox("Schedule Code not found!", MsgBoxStyle.Information, "ERROR")<br /> btn_next.Enabled = False<br /> End If<br /> dr.Close()<br /> Catch ex As Exception<br /> '' Display error<br /> MsgBox(ex.ToString)<br /> Finally<br /> '' Close Connection<br /> connection.Close()<br /> End Try<br /> End Sub</pre><br /> <br />

推荐答案

您必须将此整体方法分解为较小的步骤,然后将其分解为自己的方法.您需要开始根据状态"进行思考.您可以在用户操作时维护表单或应用程序的状态.如果他们在表单的控件中添加值或给您其他输入,则应该触发表单或应用程序其他部分的更新,以便用户可以对其进行操作. 由于要做家庭作业这件事很累,所以我不能做更多的事情了.如果有人给您一个直接的答案,那么他们就不会帮您任何忙. You have to break this monolithic method down into smaller steps and break those out into their own methods. You''ll need to start thinking in terms of "state". You maintain the state of a form or application while the user manipulates it. If they put a value in a control on the form or give you some other input, that should trigger an update of some other part of the form or application so the user can manipulate that. I can''t go into much more than that, since this reeks of a homework assignment. If anyone gives you an outright answer, they''re not doing you any favors.

更多推荐

等待用户输入,然后odbcdatareader再次读取

本文发布于:2023-06-08 23:38:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/591039.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户   odbcdatareader

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!