虽然reader.read正在跳过HELP XD [英] While reader.read is skipping HELP XD
本文介绍了虽然reader.read正在跳过HELP XD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Dim networkInterface = System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()
Dim firstNetwork = networkInterface.FirstOrDefault(Function(x As System.Net.NetworkInformation.NetworkInterface) _
x.OperationalStatus = System.Net.NetworkInformation.OperationalStatus.Up)
Dim firstMacAddressOfWorkingNetworkAdapter = firstNetwork.GetPhysicalAddress()
Dim connString As String = "Server=tserver;Database=database;Uid=usr;Pwd=ps;"
Dim sqlQuery As String = "SELECT * FROM Computers WHERE MacAddress='" & firstMacAddressOfWorkingNetworkAdapter.ToString & "'"
Dim command As MySqlCommand
Dim mysqlconn = New MySqlConnection
Dim reader As MySqlDataReader
mysqlconn.ConnectionString = connString
mysqlconn.Open()
Try
command = New MySqlCommand(sqlQuery, mysqlconn)
reader = command.ExecuteReader
While reader.Read
If firstMacAddressOfWorkingNetworkAdapter.ToString = reader.GetString("MacAddress") Then
Consoletxt("Computer Found '" + reader.GetString("ComputerName") + "'")
Consoletxt("MAC Address OK -- " + firstMacAddressOfWorkingNetworkAdapter.ToString)
Login.Domain.Text = reader.GetString("Domain")
Else
Consoletxt("Could not find your computer in our database")
Consoletxt("Starting Setup")
Thread.Sleep(5000)
SetupBackground.Mode.Text = "domain"
MyBase.Update()
SetupBackground.Show()
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
Check.Text = "setup"
End If
End While
Catch ex As Exception
End Try
mysqlconn.Close()
我试图让这段代码工作,但它只是跳过了读者。因某种原因阅读。我所有的其他作品都是相似的,但它们都有效。
任何人都可以提供帮助:/?
I've tried to get this code to work but it just skips the while reader.read for some reason. All of my other pieces where set out similar but they all work.
Can anyone help :/ ?
推荐答案
您处理异常的方式实际上隐藏了它们的发生。如果 DataReader
抛出,你永远不会知道。请合理处理异常,以便有效地调试你的程序。
Your way of handling the exceptions in fact hides their occurrence. If the DataReader
throws, you'll never know. Please handle sensibly the exceptions, in order to debug effectively your program.
谢谢你们。
i没有忘记当没有记录它是什么时发现它并没有告诉你。我发现我的数据库中的mac地址是一个错误的字符,因此它会跳过reader.read()。我现在觉得很傻但是哦。我不断添加断点试图找到错误,但直到我查看我的数据库才能。
再次感谢大家,
Alex
Thanks Guys.
i didn't forgot that when there is not record of what it is finding it does not tell you. I found that my mac address in my database a wrong character thus it would just skip the reader.read(). I kinda feel stupid now but oh well. I kept adding breakpoints trying to find the error but couldn't until i looked at my database.
Thanks guys once again,
Alex
这篇关于虽然reader.read正在跳过HELP XD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文