alter table t_g add column " & Text1.Text & " integer default = 0

解决方案 »

  1.   

    你这里的default = 0就已经表明not null,再说not null适用于字符串!
      

  2.   

    cmd.ActiveConnection = cnn
        cmd.CommandType = adCmdText
        cmd.CommandText = "alter table users add my_col INTEGER NOT NULL Default=0"
        cmd.Execute
    Passed!
    Vb6.0(sp5)
    access 2000
    jet 4.0
    Ado 2.1
      

  3.   

    dbs.Execute ("alter table t_g add column " & Text1.Text & " integer not null default 0")
      

  4.   

    or:    cmd.CommandText = "alter table users add my_col4 INTEGER DEFAULT=0"
      

  5.   

    dbs.Execute ("alter table t_g add column " & Text1.Text & " integer not null default 0")Passed!
    Vb6.0
    access 97
    jet 4.0
    Ado 2.1
      

  6.   

    win98       access97 jet3.51
    原文如下:Dim dbs As Database
    Set dbs = OpenDatabase("d:/mywork/db_stu", False, False, ";pwd =1")
    If Option1.Value = True Then
    dbs.Execute ("alter table t_g add column  " & Text1.Text & "  integer default=0")
    ElseIf Option2.Value = True Then
    dbs.Execute ("alter table t_g drop column " & Text1.Text)
    End If
    dbs.Close