VB.NET数据库查询结果显示在TextBox中
PrivateSubWorktime_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMy...
Private Sub Worktime_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim username = TextBox2.Text
Dim myconn As New SqlConnection("Initial Catalog=job;Data Source=.;" & "Integrated Security=SSPI;")
Dim sql As String = "SELECT WorkTime,ManagerCode FROM T_Manager WHERE UserName ='" & username & "'"
Dim mycmd As New SqlCommand
mycmd.Connection = myconn
mycmd.CommandText = sql
Dim myadapter As New SqlDataAdapter(mycmd)
Dim mydataset As New DataSet
myadapter.Fill(mydataset, "WorkTime")
myconn.Open()
TextBox1.DataBindings.Add("Text", mydataset, "WorkTime")
myconn.Close()
End Sub
代码没有提示错误,可以运行,但是文本框内是空,将查询语句放到数据库中的查询分析器是有结果的,求大神帮忙看看哪里出了问题???!!! 展开
Dim username = TextBox2.Text
Dim myconn As New SqlConnection("Initial Catalog=job;Data Source=.;" & "Integrated Security=SSPI;")
Dim sql As String = "SELECT WorkTime,ManagerCode FROM T_Manager WHERE UserName ='" & username & "'"
Dim mycmd As New SqlCommand
mycmd.Connection = myconn
mycmd.CommandText = sql
Dim myadapter As New SqlDataAdapter(mycmd)
Dim mydataset As New DataSet
myadapter.Fill(mydataset, "WorkTime")
myconn.Open()
TextBox1.DataBindings.Add("Text", mydataset, "WorkTime")
myconn.Close()
End Sub
代码没有提示错误,可以运行,但是文本框内是空,将查询语句放到数据库中的查询分析器是有结果的,求大神帮忙看看哪里出了问题???!!! 展开
1个回答
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询