السلام عليكم
عندي مشكلة التواريخ الي ابغاها بالهجري
فعملت حاجه انه الداتا بيس الحقل يكون عباره عن nvarchar8
وطريقة الادخال تكون عن طريق الدروب داون ليست بالكود التالي
<asp:DropDownList ID="DDL_Day" runat="server">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
<asp:ListItem>13</asp:ListItem>
<asp:ListItem>14</asp:ListItem>
<asp:ListItem>15</asp:ListItem>
<asp:ListItem>16</asp:ListItem>
<asp:ListItem>17</asp:ListItem>
<asp:ListItem>18</asp:ListItem>
<asp:ListItem>19</asp:ListItem>
<asp:ListItem>20</asp:ListItem>
<asp:ListItem>21</asp:ListItem>
<asp:ListItem>22</asp:ListItem>
<asp:ListItem>23</asp:ListItem>
<asp:ListItem>24</asp:ListItem>
<asp:ListItem>25</asp:ListItem>
<asp:ListItem>26</asp:ListItem>
<asp:ListItem>27</asp:ListItem>
<asp:ListItem>28</asp:ListItem>
<asp:ListItem>29</asp:ListItem>
<asp:ListItem>30</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DDL_Month" runat="server" Width="36px">
<asp:ListItem>01</asp:ListItem>
<asp:ListItem>02</asp:ListItem>
<asp:ListItem>03</asp:ListItem>
<asp:ListItem>04</asp:ListItem>
<asp:ListItem>05</asp:ListItem>
<asp:ListItem>06</asp:ListItem>
<asp:ListItem>07</asp:ListItem>
<asp:ListItem>08</asp:ListItem>
<asp:ListItem>09</asp:ListItem>
<asp:ListItem>10</asp:ListItem>
<asp:ListItem>11</asp:ListItem>
<asp:ListItem>12</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DDL_Year" runat="server">
<asp:ListItem>1430</asp:ListItem>
<asp:ListItem>1431</asp:ListItem>
<asp:ListItem>1432</asp:ListItem>
<asp:ListItem>1433</asp:ListItem>
<asp:ListItem>1434</asp:ListItem>
<asp:ListItem>1435</asp:ListItem>
<asp:ListItem>1436</asp:ListItem>
<asp:ListItem>1437</asp:ListItem>
<asp:ListItem>1438</asp:ListItem>
<asp:ListItem>1439</asp:ListItem>
<asp:ListItem>1440</asp:ListItem>
<asp:ListItem>1441</asp:ListItem>
<asp:ListItem>1442</asp:ListItem>
<asp:ListItem>1443</asp:ListItem>
<asp:ListItem>1444</asp:ListItem>
<asp:ListItem>1445</asp:ListItem>
<asp:ListItem>1446</asp:ListItem>
<asp:ListItem>1447</asp:ListItem>
<asp:ListItem>1448</asp:ListItem>
<asp:ListItem>1449</asp:ListItem>
<asp:ListItem>1450</asp:ListItem>
</asp:DropDownList>طيب لاني جربت موضوع الدوال واحيانا يتاخر التاريخ الهجري عن الميلادي فحيسبب مشكلة
ف كود الادخال كتبت التالي
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New SqlConnection(Web.Configuration.WebConfigurationManager.ConnectionStrings("CenterDBConnectionString").ConnectionString)
Dim sqlCom As New SqlCommand
Dim Trnsc As SqlTransaction
Try
Dim HijriDate As String
HijriDate = DDL_Year.SelectedValue & DDL_Month.SelectedValue & DDL_Day.SelectedValue
Trnsc = conn.BeginTransaction()
conn.Open()
sqlCom.Connection = conn
sqlCom.CommandText = "insert into ActivitiesTable(ActivityName ,Aims, Description ,DateOfActivity, CommitteeID)VALUES(@Name, @Aims, @Desc, @Date, @Committee) "
sqlCom.Parameters.AddWithValue("@Name", TxtName.Text)
sqlCom.Parameters.AddWithValue("@Aims", TxtAims.Text)
sqlCom.Parameters.AddWithValue("@Desc", TxtDesc.Text)
sqlCom.Parameters.AddWithValue("@Date", HijriDate)
sqlCom.Parameters.AddWithValue("@Committee", DropDownList1.SelectedValue)
sqlCom.ExecuteNonQuery()
sqlCom.Transaction = Trnsc
Trnsc.Commit()
lblMsg.Text = "تم اضافة المشروع بنجاح"
GridView1.DataBind()
Catch ex As Exception
Finally
conn.Close()
TxtName.Text = String.Empty
TxtAims.Text = String.Empty
TxtDesc.Text = String.Empty
End Try
End Subفي كود لاقيته لاسترجاع القيم ع شكل تاريخ مو ارقام
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim conn As New SqlConnection(Web.Configuration.WebConfigurationManager.ConnectionStrings("UserManagement").ConnectionString)
Dim comm As New SqlCommand
Dim adpt As New SqlDataAdapter
Dim result As New DataTable
comm.CommandText = "SELECT SUBSTRING(HIJRI_DATE,7,2) AS DAY,SUBSTRING(HIJRI_DATE,5,2) AS MONTH,SUBSTRING(HIJRI_DATE,1,4) AS YEAR FROM TABLE1 "
comm.Connection = conn
adpt.SelectCommand = comm
Try
adpt.Fill(result)
DDL_Day.SelectedValue = result.Rows(0).Item("DAY").ToString
DDL_Month.SelectedValue = result.Rows(0).Item("MONTH").ToString
DDL_Year.SelectedValue = result.Rows(0).Item("YEAR").ToString
Catch ex As Exception
Throw ex
Finally
conn.Close()
End Try
End Subسؤالي هذا كود الاسترجاع لما نضغط بوتن
طيب انا ابغاها ف القريد فيو فين احط هذا الكود او هل في كود احطه ع الداتا بيس يرجع لي قيم السترنج بفواصل مثل التاريخ
ثانيااذا كنت حرتب تبعا للتاريخ كيف حسوي؟؟؟