首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

怎么把text1.text作为日期存入access数据库

2012-03-11 
如何把text1.text作为日期存入access数据库?多谢各位大虾。下面的程序调试,总显示INSERTINTO语法错误除日期

如何把text1.text作为日期存入access数据库?
多谢各位大虾。

下面的程序调试,总显示INSERT   INTO语法错误
除日期外,所有access   fields都是文本。
我用val(dtpicker1)来存入access是否有错?
如何把text1.text作为日期存入access数据库?


Private   Sub   Command1_Click()
Dim   sql   As   String
Dim   rst   As   ADODB.Recordset
Dim   con   As   New   ADODB.Connection
Dim   j   As   Integer

                Set   con   =   New   ADODB.Connection
              con.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=CustInfo9797.mdb;Persist   Security   Info=False "
              con.CursorLocation   =   adUseClient
              con.Open
              Set   rst   =   con.Execute( "select   *   from   CustInfo ")
              j   =   rst.RecordCount
                If   Text2.Text   =   " "   Then
                i   =   MsgBox( "这是必填字段! ",   vbOKCancel,   "警告 ")
                        If   i   =   1   Then
                                Text2.SetFocus
                        Else
                                Me.Hide
                        End   If
                Else
          j   =   j   +   1
             
          con.Execute   ( "insert   into   CustomerInfo   (user,RecdDate,Com,legalRep,Kwd,BusiNature,MktBrd,Credit,Bank,Account,TaxNo,Country,Province,City,Add,Zip,Profile,Contact,Gender,   Title,Mobile,Tel,Fax,Email,Web) "   _
&   "   select   ' "   &   CStr(j)   &   " ', ' "   &   Trim(Text24.Text)   &   " ', ' "   &   (DTPicker1.Value)   &   " ', ' "   &   Trim(Text2.Text)   &   " ', ' "   &   Trim(Text3.Text)   &   " ', ' "   &   Trim(Text4.Text)   &   " ', ' "   &   Trim(Text6.Text)   &   " ', ' "   &   Trim(Text7.Text)   &   " ', ' "   &   Trim(Combo2.Text)   &   " ', ' "   &   Trim(Text8.Text)   &   " ', ' "   &   Trim(Text9.Text)   &   " ', ' "   &   Trim(Text10.Text)   &   " ', ' "   &   Trim(Text11.Text)   &   " ', ' "   &   Trim(Text12.Text)   &   " ', ' "   &   Trim(Text13.Text)   &   " ', ' "   &   Trim(Text14.Text)   &   " ', ' "   &   Trim(Text15.Text)   &   " ', ' "   &   Trim(Text16.Text)   &   " ', ' "   &   Trim(Text17.Text)   &   " ', ' "   &   Trim(Combo1.Text)   &   " ', ' "   &   Trim(Text18.Text)   &   " ', ' "   &   Trim(Text19.Text)   &   " ', ' "   &   Trim(Text20.Text)   &   " ', ' "   &   Trim(Text21.Text)   &   " ', ' "   &   Trim(Text22.Text)   &   " ', ' "   &   Trim(Text23.Text)   &   " ' ")


     
     
                      MsgBox   "数据添加成功! ",   vbOKOnly,   "恭喜! "
                End   If


end   sub


[解决办法]
DTPICKER1.VALUE
YOU 'D BETTER NOT USE TEXT1.BOX,USE DTPICKER IS MUCH BETTER
YOU HAV TO FORMAT TEXTBOX BEFORE INSERT IT

[user],RecdDate,[Com],legalRep,Kwd,BusiNature,MktBrd,[Credit],[Bank],[Account],TaxNo,[Country],[Province],City,[Add],Zip,Profile,Contact,Gender, Title,Mobile,Tel,Fax,Email,[Web]

RESERVED WORD SHOULD HAVE[]

热点排行