G
Guest
What must I do to overcome a problem with my dates becoming formatted as
"2/22/2525 12:00:00 AM" in the datagrid? I want to handle all dates as
short string of format "2/22/2525." Otherwise when I run the update routine
SQL (set start_date = "2/22/2525 12:00:00 AM") does not work while short
string (set date = '2/22/2525') does work. See update routine below:
Private Sub MarketingDataGrid_UpdateCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
MarketingDataGrid.UpdateCommand
Dim ErrorMessage As String = Session("ErrorMessage")
Dim ad_nameText As TextBox = CType(e.Item.Cells(3).Controls(0),
TextBox)
Dim advertisement_name As String = ad_nameText.Text
Dim start_dateText As TextBox = CType(e.Item.Cells(4).Controls(0),
TextBox)
Dim start_date As String = start_dateText.Text
Dim expiration_dateText As TextBox =
CType(e.Item.Cells(5).Controls(0), TextBox)
Dim expiration_date As String = expiration_dateText.Text
Dim ad_typeText As TextBox = CType(e.Item.Cells(6).Controls(0),
TextBox)
Dim ad_type As String = ad_typeText.Text
Dim advertiserText As TextBox = CType(e.Item.Cells(7).Controls(0),
TextBox)
Dim advertiser As String = advertiserText.Text
Dim advertisement_descriptionText As TextBox =
CType(e.Item.Cells(8).Controls(0), TextBox)
Dim advertisement_description As String =
advertisement_descriptionText.Text
Dim source_id As String = Session("source_id")
Try
baseconnection.Close()
BICDataAdapter.UpdateCommand = ucommand
BICDataAdapter.UpdateCommand.Connection = baseconnection
baseconnection.ConnectionString = ConnectString
BICDataAdapter.UpdateCommand.CommandText = "Update Marketing set
advertisement_name = '" & advertisement_name & _
"',start_date = '" & start_date & "',expiration_date = '" &
expiration_date & "',ad_type = '" & ad_type & _
"',advertiser = '" & advertiser & "',advertisement_description =
'" & advertisement_description & _
"' where source_id = " & source_id
baseconnection.Open()
BICDataAdapter.Fill(BICDataSet, "marketing")
MarketingDataGrid.DataSource = BICDataSet.Tables("MARKETING")
MarketingDataGrid.DataBind()
"2/22/2525 12:00:00 AM" in the datagrid? I want to handle all dates as
short string of format "2/22/2525." Otherwise when I run the update routine
SQL (set start_date = "2/22/2525 12:00:00 AM") does not work while short
string (set date = '2/22/2525') does work. See update routine below:
Private Sub MarketingDataGrid_UpdateCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
MarketingDataGrid.UpdateCommand
Dim ErrorMessage As String = Session("ErrorMessage")
Dim ad_nameText As TextBox = CType(e.Item.Cells(3).Controls(0),
TextBox)
Dim advertisement_name As String = ad_nameText.Text
Dim start_dateText As TextBox = CType(e.Item.Cells(4).Controls(0),
TextBox)
Dim start_date As String = start_dateText.Text
Dim expiration_dateText As TextBox =
CType(e.Item.Cells(5).Controls(0), TextBox)
Dim expiration_date As String = expiration_dateText.Text
Dim ad_typeText As TextBox = CType(e.Item.Cells(6).Controls(0),
TextBox)
Dim ad_type As String = ad_typeText.Text
Dim advertiserText As TextBox = CType(e.Item.Cells(7).Controls(0),
TextBox)
Dim advertiser As String = advertiserText.Text
Dim advertisement_descriptionText As TextBox =
CType(e.Item.Cells(8).Controls(0), TextBox)
Dim advertisement_description As String =
advertisement_descriptionText.Text
Dim source_id As String = Session("source_id")
Try
baseconnection.Close()
BICDataAdapter.UpdateCommand = ucommand
BICDataAdapter.UpdateCommand.Connection = baseconnection
baseconnection.ConnectionString = ConnectString
BICDataAdapter.UpdateCommand.CommandText = "Update Marketing set
advertisement_name = '" & advertisement_name & _
"',start_date = '" & start_date & "',expiration_date = '" &
expiration_date & "',ad_type = '" & ad_type & _
"',advertiser = '" & advertiser & "',advertisement_description =
'" & advertisement_description & _
"' where source_id = " & source_id
baseconnection.Open()
BICDataAdapter.Fill(BICDataSet, "marketing")
MarketingDataGrid.DataSource = BICDataSet.Tables("MARKETING")
MarketingDataGrid.DataBind()