扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
数据库中 age 字段,birthday 字段是什么类型?都不是字符型吧。。。
成都创新互联公司是一家专业提供周口企业网站建设,专注与网站建设、成都做网站、成都h5网站建设、小程序制作等业务。10年已为周口众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
=======================================================
birthday 是数字?不太可能吧。。。难道你不是用来存放生日的!
要真是 数字 你这样写试试
MyCommand = New OleDbCommand("UPDATE yggrxx SET name ='" TextBox2.Text "',sex = '" TextBox3.Text "',age =" TextBox4.Text ",birthday = " val(TextBox5.Text) ", address = '" TextBox6.Text "', postid = " TextBox7.Text ", pwd = '" TextBox8.Text "' where id = " TextBox1.Text, MyConnection)
要是是 日期/时间 你这样写试试
MyCommand = New OleDbCommand("UPDATE yggrxx SET name ='" TextBox2.Text "',sex = '" TextBox3.Text "',age =" TextBox4.Text ",birthday = #" TextBox5.Text "#, address = '" TextBox6.Text "', postid = " TextBox7.Text ", pwd = '" TextBox8.Text "' where id = " TextBox1.Text, MyConnection)
VB6中,在使用Select语句的Where子句时:
对于字符型,要用单引号:
Where 字段名=' " 字符型变量 "'"
而对于日期型,要用井字号“#”:
Where 日期型字段名=# " 日期型变量 "#"
对于VB.net,应该是一样的道理,你可以按照VB6试试。
Imports System.Text.RegularExpressions
Public Class Form1
Public Function MadeRegexArray(ByVal strText As String, ByVal strRegx As String, ByVal rexOpt As RegexOptions, ByVal Groups As Integer) As String()
REM 正则结果直接以字符串组形式返回
REM strHtml待搜索的字符串
REM strRegx正则表达式
REM rexOpt正则选项
On Error Resume Next
Return MadeMatchString(MadeRegexMatch(strText, strRegx, rexOpt), Groups)
End Function
Public Function MadeMatchString(ByVal mc As MatchCollection, ByVal Groups As Integer) As String()
REM 把MatchCollection以字符串组形式保存
REM mc正则匹配的集合
REM 返回字符串组
On Error Resume Next
Dim strRegCode(mc.Count) As String
For i As Integer = 0 To mc.Count - 1
strRegCode(i) = mc(i).Groups(Groups).Value
Next i
Return strRegCode
End Function
Public Function MadeRegexMatch(ByVal strText As String, ByVal strRegex As String, ByVal rexOpt As RegexOptions) As MatchCollection
REM 获取正则表达式匹配的集合
REM strHtml待正则的字符串
REM strRegex正则表达式
REM rexOpt正则选项
REM 返回 MatchCollection 类型集合
On Error Resume Next
Dim rex As Regex = New Regex(strRegex, rexOpt)
Return rex.Matches(strText)
End Function
Public Function MadeRegexReplace(ByVal sText As String, ByVal sRegex As String, ByVal sReplace As String) As String
REM 正则表达式文本替换
REM sText原文本
REM sRegex表达式
REM sReplace替换文本
On Error Resume Next
Dim rex As Regex = New Regex(sRegex, RegexOptions.IgnoreCase)
Return rex.Replace(sText, sReplace)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim sRegex As String = "([\s\S]*?)"
Dim aTable() As String = MadeRegexArray(TextBox1.Text, sRegex, RegexOptions.IgnoreCase, 1)
For i As Integer = 0 To aTable.Length - 1
TextBox2.Text = TextBox2.Text aTable(i)
Next i
End Sub
End Class
如图:
正则表达式是:
/[a-zA-Z/]+$
如果要把第一个斜杠去掉,就是匹配index/index/index,用后向匹配,正则是:
(?=/)[a-zA-Z/]+$
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流