我在文本框中写的时候使用此代码来建议名称。 如果没有更多的建议,我想展示一个新表格,但我不知道如何计算建议的。
任何人都可以帮助我吗?
提前致谢并抱歉我的英语。
If txt_nome.Text.Length >= 3 Then
Using con As NpgsqlConnection = GetConnection()
Dim sql As String
sql = "SELECT nome FROM dados_pessoais"
Dim cmd As NpgsqlCommand = New NpgsqlCommand(sql, con)
Dim da As NpgsqlDataAdapter = New NpgsqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "list")
Dim col As New AutoCompleteStringCollection
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
col.Add(ds.Tables(0).Rows(i)("nome").ToString())
Next
txt_nome.AutoCompleteSource = AutoCompleteSource.CustomSource
txt_nome.AutoCompleteCustomSource = col
txt_nome.AutoCompleteMode = AutoCompleteMode.Suggest
End Using
End If
End Sub
答案 0 :(得分:-1)
请你试试这个
Dim c As New NsqlConnection(GetConnection)
Dim cmd As New NsqlCommand
Dim da As New NsqlDataAdapter
Dim dr As NsqlDataReader
Dim ds, ds1 As New DataSet
然后将其粘贴到公共类
中的任何位置Sub CountNumbers
Dim x as integer
Try
ds.Clear()
c.Open()
cmd = New NsqlCommand("SELECT Count(nome) FROM dados_pessoais", c)
da = New NsqlDataAdapter(cmd)
da.Fill(ds, "dados_pessoais")
x = ds.Tables(0).Rows(0).Item(0)
if x = 0 then
'Go to your Form
else
'Do Nothing
end if
Catch ex As Exception
MsgBox(ex.Message)
Finally
c.Close()
End Try
End Sub
在上面的代码中写下这个
CountNumbers
在结束子
之上我写这个没有尝试,如果这个工作,但如果不是,我会帮助你的错误。这是一个很长的方法,但我确定有一个短的