在我的SQLite数据库中,我有一个 nvarchar 列。但是当选择此列时,要选择30个第一个字符。我测试 substr 和子串但不是真的。 我怎样才能做到这一点? 感谢
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
中答案 0 :(得分:1)
好吧,既然您没有发布代码,获取部分文本的基本语法是:
所以你可以这样做:
SELECT SUBSTR(field_name,0,30) FROM your_table;
请参阅:Reference