Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何使用textchange填充其他字段_Asp.net_Vb.net - Fatal编程技术网

Asp.net 如何使用textchange填充其他字段

Asp.net 如何使用textchange填充其他字段,asp.net,vb.net,Asp.net,Vb.net,这是我的代码,任何帮助都将不胜感激。 一旦我在txtbarcode.text上键入productid,如果它存在于我的数据库中,它应该填充我的txtitemdesc.textbox Protected Sub txtbarcode_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtbarcode.TextChanged Dim con As SqlConnection = New SqlConnect

这是我的代码,任何帮助都将不胜感激。 一旦我在txtbarcode.text上键入productid,如果它存在于我的数据库中,它应该填充我的txtitemdesc.textbox

Protected Sub txtbarcode_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtbarcode.TextChanged
    Dim con As SqlConnection = New SqlConnection("Data Source = pc11-pc\kim; Initial Catalog = convertpos; User Id = sa; Password = 123")
    con.Open()
    Dim sqlstr As String = ("Select * from Product where ProductID = @ProductID")
    Dim cmd As SqlCommand = New SqlCommand(sqlstr, con)
    cmd.Parameters.AddWithValue("@ProductID", txtbarcode.Text)

    Dim reader As SqlDataReader = cmd.ExecuteReader()
    If reader.HasRows Then
        reader.Read()
        txtitemdesc.Text = reader("ProductName").ToString()
        MsgBox(reader("ProductName").ToString())
    End If
    con.Close()
End Sub

有什么问题?您的代码在哪里失败/发生了什么?是否有任何输出或错误消息?实际上,先生,当我将msgbox放在那里时,txtitemdesc将填充,否则它将不会填充=(我也不明白,但看起来你有一些渲染更新问题…我不知道那里有什么问题!但是当我输入条形码时,它应该填充txtitemdesc.text。我把消息框放在那里,看看它是否提取了一些数据,它确实提取了。但是如果我删除msgbox,它将不会提取任何信息。或者可能像你一样我可能在渲染时遇到问题。