【发布时间】:2021-11-09 13:32:36
【问题描述】:
我有一个 DataGrid 视图,它绑定到数据库并像这样从 MySql 数据库中获取信息。
MySqlCommand cmd3 = new MySqlCommand("SELECT * FROM owner_units WHERE unit_id =" + UNITID, conn);
MySqlDataAdapter adp2 = new MySqlDataAdapter(cmd3);
DataSet ds2 = new DataSet();
adp2.Fill(ds2, "LoadDataBinding2");
owner_unit.DataContext = ds2;
然后我像这样将数据库中的数据添加到我的 DataGrid 视图中。
<DataGrid HorizontalAlignment="Left" Name="owner_unit" ItemsSource="{Binding LoadDataBinding2}" AutoGenerateColumns="False" IsReadOnly="True" CanUserAddRows="False" Height="99" Margin="36,463,0,0" VerticalAlignment="Top" Width="420">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding id}" Header="OwnerID" Width="100" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding percent}" Header="Percentage" Width="100" IsReadOnly="True" />
<DataGridTextColumn Binding="{Binding register_date}" Header="sell date " Width="200" IsReadOnly="True" />
</DataGrid.Columns>
</DataGrid>
我的问题是我的名为 register_date 的数据库列在 Miladi 日期 (2021/11/09) 中,我想将其更改为波斯 (Shamsi) 日期 (18/08/1400)。
【问题讨论】:
-
请不要使用 sql 连接字符串,仅使用参数见stackoverflow.com/questions/11070434/…
-
@nbk 我不明白这与我的问题有什么关系。
-
@ArsalanAhmadi 这是一条评论,旨在为您提供一些对您的程序至关重要的信息。进一步简短搜索找到stackoverflow.com/questions/30683664/… 也 mysql 在 2021-01-01 保存数据保持这样,在 mysql 中转换是昂贵的
-
这能回答你的问题吗? How convert Gregorian date to Persian date?