0

在我的 SQLite 数据库中,我有一个nvarchar列。But when select this column, want to select 30 first character. 我测试substrsubstring但不是真的。我怎样才能做到这一点?谢谢

public static DataTable FetchNotesList(int PointId)
            {
                DataTable FetchNotesListDataTable = new DataTable();
                using (SQLiteConnection FetchNotesListConnection = new SQLiteConnection(BLL.SettinClass.IASQLiteConnectionString))
                {
                    FetchNotesListConnection.Open();

                    SQLiteCommand FetchNotesListCommand = new SQLiteCommand();//FetchNotesListConnection.CreateCommand();
                    FetchNotesListCommand.Connection = FetchNotesListConnection;
                    FetchNotesListCommand.CommandText = "SELECT NoteId, SUBSTR(NoteContent,0,10), NoteDate, NoteDateTime FROM PointsNotes WHERE PointsId = @PointId";
                    FetchNotesListCommand.Parameters.AddWithValue("PointId", PointId);
                    SQLiteDataAdapter FetchNotesListDataAdapter = new SQLiteDataAdapter(FetchNotesListCommand);
                    FetchNotesListDataAdapter.Fill(FetchNotesListDataTable);
                }

                return FetchNotesListDataTable;
            }

我使用此代码。日期列显示但notecontent不显示在gridex中

4

1 回答 1

1

好吧,由于您尚未发布代码,因此获取部分文本的基本语法是:

  • SUBSTR(字段名称,开始位置)
  • SUBSTR(field_name,start_location,substring_length)

因此,您可以执行以下操作:

SELECT SUBSTR(field_name,0,30) FROM your_table; 

请参阅:参考

于 2012-06-24T07:35:57.523 回答