1、在SQL语句里用IIF(A=true,"是","否")2、居然显示*,那还显示这个字段干吗?

解决方案 »

  1.   

    第1个问题:
    DataGrid1.Columns("是否").NumberFormat = "是;否"’分号隔开!
    先给一半以上的分,如何?思路已经是这样啦!请回复我的一个帖子:
    http://www.csdn.net/expert/topic/654/654811.xml?temp=.8152735
    主题:  我自认VB水平不错,请大家给我估估价!
      

  2.   

    第2个问题,如果从SQL方面解决,可以用:
    select 表1.用户名,……, String(len(密码),"*") as 口令  from 表1
    给分?
      

  3.   

    1.datagrid控件中右鍵屬性中,選擇format頁,選取boolean:true value填"是" false value填"否"
    2.密碼還是不顯示為好
      

  4.   

    两个方法:
    1:自己封装一个DataGrid控件,或者使用FORMAT将字符格式化掉,在显示出来。
    你不要使用DataGrid控件,可以使用H Grid控件,它可以直接帮定记录集。
      

  5.   

    1、在SQL语句里用IIF(A=true,"是","否")
      

  6.   

    jameszht(湖泊)
     你说的方法不灵 tian_tiger(老虎)
    你的方法超出要求dragoncity(自己发工资) 
    你的帖子我已经回了,请帖出详细的例子代码.决不少分!针对的是:ACCESS
      

  7.   

    SELECT IIf([boolean字段],"是","否") AS FYesorNo, IIf(Password字段=Password,"*********","") As Fpass [From your table Name]
      

  8.   

    ??你的帖子我已经回了,请帖出详细的例子代码.决不少分!针对的是:ACCESS第1个问题:
    DataGrid1.Columns("是否").NumberFormat = "是;否"’分号隔开!
    思路已经是这样啦!  第2个问题,如果从SQL方面解决,可以用:
    select 表1.用户名,……, String(len(密码),"*") as 口令  from 表1这不是很详细了么?再怎么详细呢?把你的需要再详细形容一下?
     
     
      

  9.   

    建立新工程,添加DataGrid控件和ADODC控件到工具箱中,把默认添加的Form1删除,然后把下面的代码存成Form1.Frm文件,添加到你的工程中。有问题再找我!VERSION 5.00
    Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
    Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
    Begin VB.Form Form1 
       Caption         =   "Form1"
       ClientHeight    =   4755
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   8025
       LinkTopic       =   "Form1"
       ScaleHeight     =   4755
       ScaleWidth      =   8025
       StartUpPosition =   3  '窗口缺省
       Begin VB.CommandButton Command1 
          Caption         =   "Command1"
          Height          =   255
          Left            =   3000
          TabIndex        =   1
          Top             =   120
          Width           =   1455
       End
       Begin MSDataGridLib.DataGrid DataGrid1 
          Bindings        =   "Form1.frx":0000
          Height          =   4215
          Left            =   120
          TabIndex        =   0
          Top             =   480
          Width           =   7815
          _ExtentX        =   13785
          _ExtentY        =   7435
          _Version        =   393216
          HeadLines       =   1
          RowHeight       =   15
          BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
             Name            =   "宋体"
             Size            =   9
             Charset         =   134
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
             Name            =   "宋体"
             Size            =   9
             Charset         =   134
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          ColumnCount     =   2
          BeginProperty Column00 
             DataField       =   ""
             Caption         =   ""
             BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                Type            =   0
                Format          =   ""
                HaveTrueFalseNull=   0
                FirstDayOfWeek  =   0
                FirstWeekOfYear =   0
                LCID            =   2052
                SubFormatType   =   0
             EndProperty
          EndProperty
          BeginProperty Column01 
             DataField       =   ""
             Caption         =   ""
             BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
                Type            =   0
                Format          =   ""
                HaveTrueFalseNull=   0
                FirstDayOfWeek  =   0
                FirstWeekOfYear =   0
                LCID            =   2052
                SubFormatType   =   0
             EndProperty
          EndProperty
          SplitCount      =   1
          BeginProperty Split0 
             BeginProperty Column00 
             EndProperty
             BeginProperty Column01 
             EndProperty
          EndProperty
       End
       Begin MSAdodcLib.Adodc Adodc1 
          Height          =   375
          Left            =   120
          Top             =   0
          Width           =   1455
          _ExtentX        =   2566
          _ExtentY        =   661
          ConnectMode     =   0
          CursorLocation  =   3
          IsolationLevel  =   -1
          ConnectionTimeout=   15
          CommandTimeout  =   30
          CursorType      =   3
          LockType        =   3
          CommandType     =   1
          CursorOptions   =   0
          CacheSize       =   50
          MaxRecords      =   0
          BOFAction       =   0
          EOFAction       =   0
          ConnectStringType=   1
          Appearance      =   1
          BackColor       =   -2147483643
          ForeColor       =   -2147483640
          Orientation     =   0
          Enabled         =   -1
          Connect         =   $"Form1.frx":0015
          OLEDBString     =   $"Form1.frx":009E
          OLEDBFile       =   ""
          DataSourceName  =   ""
          OtherAttributes =   ""
          UserName        =   ""
          Password        =   ""
          RecordSource    =   "select 表1.*, String(len(密码),""*"") as 口令 from 表1"
          Caption         =   "Adodc1"
          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
             Name            =   "宋体"
             Size            =   9
             Charset         =   134
             Weight          =   400
             Underline       =   0   'False
             Italic          =   0   'False
             Strikethrough   =   0   'False
          EndProperty
          _Version        =   393216
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option ExplicitPrivate Sub Command1_Click()
    Rem SQL语句:select 表1.*, String(len(密码),"*") as 口令 from 表1
        With DataGrid1
            .Columns("密码").NumberFormat = "**"
            .Columns("是否").NumberFormat = "是;否"
        End With
    End Sub
      

  10.   

    补充:其中,语句 .Columns("密码").NumberFormat = "**" 无效。因为我现在的机器没有装MSDN,所以试不出来。用SQL的解决办法即可。
    运行后,单击“Command1”按钮,改变“是否”字段的显示格式。
      

  11.   

    datagrid控件中右鍵屬性中,選擇format頁,選取boolean:true value填"是" false value填"否" 
    要求:
    1.datagrid已有數據源Datasource。(adodc控件 或DataEnviroment)
    2.在datagrid的右鍵菜單中選retrieve fields。(獲得數據源中的字段)
    3.在format頁中的format item選擇為boolean的那一列。如果使用代碼:dim conn as new  connection
    dim rs as new recordset
    conn.open "...連接字符串..."
    rs.open "select BooleanField=case when BooleanFiled =1 then  '是' else '否' end,PasswordField='*****'",conn
    set datagrid1.datasource=rs