如何在vb.net中删除dropdownlist的试用空间。我的守则如下 [英] How to remove trial space of dropdownlist in vb.net. My Code is as follows

查看:59
本文介绍了如何在vb.net中删除dropdownlist的试用空间。我的守则如下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试

Dim asql As String =(SELECT groupname FROM tblaccountgroup)

Dim da As New OleDbDataAdapter(asql,cnnOLEDB)

Dim ds作为新数据集

da.Fill(ds)

Cmbogroup.ValueMember =groupname

Cmbogroup.DataSource = ds.Tables (0)

Cmbogroup.SelectedIndex = 0

Catch ex As Exception

MsgBox(ERROR:&ex.Message.ToString)

结束尝试

Try
Dim asql As String = ("SELECT groupname FROM tblaccountgroup")
Dim da As New OleDbDataAdapter(asql, cnnOLEDB)
Dim ds As New DataSet
da.Fill(ds)
Cmbogroup.ValueMember = "groupname"
Cmbogroup.DataSource = ds.Tables(0)
Cmbogroup.SelectedIndex = 0
Catch ex As Exception
MsgBox("ERROR : " & ex.Message.ToString)
End Try

推荐答案

(Ok Chill ^ _ ^)



Do你的意思是尾随空格?



你应该始终清理你的数据进入你的数据库。你可以使用c#& VB mystring.Trim()清理进入数据库的数据的空格。



失败,数据现在位于具有前导或尾随空格的数据库中。清理select语句中的数据:



(Ok Chill ^_^)

Do you mean "Trailing whitespace"?

You should always sanitize your data going into your database. You can use the c# & VB mystring.Trim() to clean white-spaces of your data going into the database.

Failing that, the data is now in the database with leading or trailing white-spaces. Clean the data in the select statement:

Try
  Dim asql As String = ("SELECT LTRIM(RTRIM(groupname)) FROM tblaccountgroup")
  Dim da As New OleDbDataAdapter(asql, cnnOLEDB)
  Dim ds As New DataSet
  da.Fill(ds)
  Cmbogroup.ValueMember = "groupname"
  Cmbogroup.DataSource = ds.Tables(0)
  Cmbogroup.SelectedIndex = 0
Catch ex As Exception
  MsgBox("ERROR : " & ex.Message.ToString)
End Try





希望有所帮助^ _ ^



Hope that helps ^_^


这篇关于如何在vb.net中删除dropdownlist的试用空间。我的守则如下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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