本文介绍了如何将这个mysql查询结果放入一个标签VB.NET中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我尝试了很多事情,但没有任何工作 我现在有这个代码,我怎么能把它放到标签上? b $ b Dim LeitorSQL2 As MySqlDataReader Dim conn As 新 MySqlConnection conn.Open() Dim Query2 As 字符串 Query2 = SELECT MAX(OcorrenciaID )+ 1作为'NovoID'FROM 8Gest.ocorrencias Dim AutoNumero = 新 MySqlCommand(Query2) LeitorSQL2 = AutoNumero.ExecuteReader while LeitorSQL2.Read Dim autonmr = LeitorSQL.GetString( NovoID) lblNumeroAuto.Text = autonmr 结束 而 conn.Close() 我的尝试: 我已经尝试了 lblNumeroAuto.Text =(autonmr) lblNumeroAuto.Text = 3 ' (这也没有用) lblNumeroAuto.Text + = autonmr 解决方案 尝试: lblNumeroAuto.Text + = autonmr 我发现了错误..这只是愚蠢的事情..我忘记了连接 Dim AutoNu mero = 新 MySqlCommand(Query2) 代码工作如果我把 Dim AutoNumero = 新 MySqlCommand(Query2,conn) Hi, I tried a lot of things to do this but nothing its workingIhave this code right now, how can I put that into the label? Dim LeitorSQL2 As MySqlDataReader Dim conn As New MySqlConnection conn.Open() Dim Query2 As String Query2 = "SELECT MAX(OcorrenciaID) + 1 as 'NovoID' FROM 8Gest.ocorrencias" Dim AutoNumero = New MySqlCommand(Query2) LeitorSQL2 = AutoNumero.ExecuteReader While LeitorSQL2.Read Dim autonmr = LeitorSQL.GetString("NovoID") lblNumeroAuto.Text = autonmr End While conn.Close()What I have tried:I already tried lblNumeroAuto.Text = (autonmr)lblNumeroAuto.Text = 3 '(This didnt work too)lblNumeroAuto.Text += autonmr 解决方案 Try: lblNumeroAuto.Text += autonmrI found the error.. Is just the stupid thing ever.. I forgot to make the connection in Dim AutoNumero = New MySqlCommand(Query2)The code work if I put Dim AutoNumero = New MySqlCommand(Query2, conn) 这篇关于如何将这个mysql查询结果放入一个标签VB.NET中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 11:07