查找数据库问题
输入字符查找数据库中内容,如果有内容则返回内容,如果没有则现在该字符
下面是我写的函数 如果数据库中有内容的已经可以成功返回 但是没有对应记录的则没有显示原来输入的字符,请帮帮忙看看是错在哪里
主要是 ElseIf (str = "") Then
TextBox2.Text = TextBox2.Text + strWords(i)
这条语句就是没有作用
代码如下:
Private Function SplitStringIntoWords() As Integer
Dim strComplete As String = TextBox3.Text '"This-is a complete sentence"
Dim strWords() As String
Dim strSeparators() As Char = {" "c, "-"c}
strWords = strComplete.Split(strSeparators)
Dim i As Integer
For i = 0 To UBound(strWords)
Try
Mycn.ConnectionString = sConnString
Mycn.Open()
Dim sComm As New SqlCommand("select word from tblAddCode where code= '" & strWords(i) & "'", Mycn)
Dim MydataReader As SqlDataReader = sComm.ExecuteReader
Dim str As String
Dim t As Integer
While MydataReader.Read
For t = 0 To MydataReader.FieldCount - 1
str = MydataReader.Item(t)
If (str <> "") Then
TextBox2.Text = TextBox2.Text + str
ElseIf (str = "") Then
TextBox2.Text = TextBox2.Text + strWords(i)
End If
Next
End While
Mycn.Close()
Catch myinformation As SqlException
MessageBox.Show(myinformation.Message)
End Try
Next
End Function
下面是我写的函数 如果数据库中有内容的已经可以成功返回 但是没有对应记录的则没有显示原来输入的字符,请帮帮忙看看是错在哪里
主要是 ElseIf (str = "") Then
TextBox2.Text = TextBox2.Text + strWords(i)
这条语句就是没有作用
代码如下:
Private Function SplitStringIntoWords() As Integer
Dim strComplete As String = TextBox3.Text '"This-is a complete sentence"
Dim strWords() As String
Dim strSeparators() As Char = {" "c, "-"c}
strWords = strComplete.Split(strSeparators)
Dim i As Integer
For i = 0 To UBound(strWords)
Try
Mycn.ConnectionString = sConnString
Mycn.Open()
Dim sComm As New SqlCommand("select word from tblAddCode where code= '" & strWords(i) & "'", Mycn)
Dim MydataReader As SqlDataReader = sComm.ExecuteReader
Dim str As String
Dim t As Integer
While MydataReader.Read
For t = 0 To MydataReader.FieldCount - 1
str = MydataReader.Item(t)
If (str <> "") Then
TextBox2.Text = TextBox2.Text + str
ElseIf (str = "") Then
TextBox2.Text = TextBox2.Text + strWords(i)
End If
Next
End While
Mycn.Close()
Catch myinformation As SqlException
MessageBox.Show(myinformation.Message)
End Try
Next
End Function
...全文
相关推荐
vs自带数据库sql server的中文插入乱码问题、查找当前数据库名
"解决vs自带数据库sql server中文插入乱码问题及查找当前数据库名的方法"在使用Visual Studio(VS)自带的SQL Server数据库时,可能会遇到中文插入后显示为乱码的问题。
气象探测数据管理系统建设方案-3.docx
- 数据存储:建立安全、可靠的数据库,实现数据的长期保存和备份。- 数据查询:用户可以根据多种条件快速查找所需数据。- 数据下载:支持用户下载历史数据以供进一步研究。
DB演员:好莱坞演员的照片数据库
在DB演员数据库中,可以使用SQL语句来查找特定演员的所有照片或某个电影的主演。6.
DB.rar_DB排序
【描述】中提到,这是一个“简单的控制台数据库”,这通常指的是一个基于命令行界面的数据管理系统,不依赖图形用户界面(GUI)。
普元元数据管理系统V5.0操作手册.pdf.zip
**接口与集成**:普元元数据管理系统V5.0可能支持与其他IT系统的接口,如BI工具、数据仓库、数据湖等,实现元数据的跨系统共享和协同。8.


