我想在id文本框中插入id时填充数据这里是我的代码但是当我插入id dept时没有显示? [英] I want to fill data when I insert the id in id text box here is my code but when I insert id dept nothing shows ?

查看:68
本文介绍了我想在id文本框中插入id时填充数据这里是我的代码但是当我插入id dept时没有显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Private Sub dept_num_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dept_num.TextChanged
        Dim con As SqlConnection = New SqlConnection("Data Source=S-MHAMEED\SQL2008RTWO;Initial Catalog=comp.task;User ID=sa;Password=likebefore")
        Using (con)

            Dim dt As New DataTable
            Dim sqlCom As New SqlCommand()
            Dim sqlDA As New SqlDataAdapter()

            sqlCom.Connection = con
            sqlCom.CommandText = "insert_dept"
            sqlCom.CommandType = CommandType.StoredProcedure
            sqlCom.Parameters.AddWithValue("dept_id", Val(dept_num.Text))
            sqlDA = New SqlDataAdapter(sqlCom)
            sqlDA.Fill(dt)

            If dt.Rows.Count Then
                dept_name.Text = dt.Rows(0).Item("debt_name")
                emp_num.Text = dt.Rows(0).Item("debt_emp")
            End If

        End Using





我尝试过:





What I have tried:

i want to fill data when i insert the id in id text box Here is my code but when i insert id dept nothing shows ??? 

推荐答案

就像你上一期的问题一样,我们还是看不懂你的SP,我们分不清是什么你的桌子看起来很划线,我们无法访问你的数据,我们可以告诉你传递的是什么。



所有这些对于解决这个问题至关重要。

所以,这取决于你。

幸运的是,你有一个工具可以帮助你找到正在发生的事情:调试器。你如何使用它取决于你的编译器系统,但是一个快速的谷歌用于你的IDE名称和调试器应该给你你需要的信息。



放一个断点在函数的第一行,并通过调试器运行代码。然后查看您的代码,并查看您的数据并找出手动应该发生的事情。然后单步执行每一行检查您预期发生的情况正是如此。如果不是,那就是当你遇到问题时,你可以回溯(或者再次运行它并仔细观察)以找出原因。
看看dept_num中究竟是什么。文本,使用SSMS来选择所有matchign行(在您查看SP以确切了解它的作用之后)并查看将要返回的内容。然后按照你的代码查看返回的内容。



抱歉,我们不能为你做到这一点 - 时间让你学习一个新的(非常,非常有用)技能:调试!
Just as with your last question, we still can't read your SP, we can't tell what your tables look line, we can't access your data, we can;t tell what you are passing.

All all of that is essential to solve this problem.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Look at exactly what is in dept_num.Text, use SSMS to SELECT all matchign rows (after you look at the SP to find out exactly what it does) and see what is going to be returned. Then follow your code through as see what is returned.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!


这篇关于我想在id文本框中插入id时填充数据这里是我的代码但是当我插入id dept时没有显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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