Jump to content
Xtreme .Net Talk

garyfis

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by garyfis

  1. The BookingID isn't the Identity Column. That is InitialObservationsID which is not being set.
  2. I am having a problem with this code only when I am trying to insert into a SQL DB when the last record in the DB has been deleted. I get an error stating that PK '5' already exists, when I am trying to insert 10 rows. This also happens when the DB is clean. Any help would be appreciated. Dim newRow As DataRow Dim X As Integer Try For X = 1 To spQuestions.DataRowCnt newRow = dsInitialObservations.tblScreeningInitial.NewRow newRow("BookingID") = _BookingID newRow("NameID") = _NameID newRow("ObservationSequence") = X spQuestions.Col = 1 spQuestions.Row = X newRow("Observation") = spQuestions.Value spQuestions.Col = 2 spQuestions.Row = X If spQuestions.Value = "1" Then newRow("Answer") = 1 Else newRow("Answer") = 0 End If spQuestions.Col = 4 spQuestions.Row = X newRow("Explanation") = IfEmpty(spQuestions.Value) newRow("CreatedAt") = Now newRow("CreatedBy") = strUserName dsInitialObservations.tblScreeningInitial.Rows.Add(newRow) Next daInitialObservations.Update(dsInitialObservations, "tblScreeningInitial") dsInitialObservations.AcceptChanges() Catch ex As Exception MessageBox.Show("Error - " & Err.Description, "Error Saving Initial Observations", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try
  3. SQL Server doesn't seem to allow just a time to be put in a DATETIME field. That's why I had to add the SQL Server default date, so that I could get only the time to appear in the field (without the date). I also tried hard coding in a time and found that then the current date was automatically entered. Perhaps the only answer to this is to hard code the default date in so that during the INSERT or UPDATE the current date isn't put in. Then the default date is hidden and only the time is visible.
  4. This code gave me only the time: #09:00:00 AM# which I wanted, but the DB would not except it. This is what I initially had: workrowMasterName("LastUpdatedTime") = CDate(FormatDateTime(Now, DateFormat.ShortTime)) This is what I just found will work: workrowMasterName("LastUpdatedTime") = CDate("1899-12-30 " & FormatDateTime(Now, DateFormat.ShortTime)) I found that if you put in the SQL Server default date, it will not show up. There has got to be a better way. Thanks for your response.
  5. I am trying to save a time to a datatime field in SQL Server 2000, but when I do, I get the following error: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. I have tried so many combinations of conversions and just hard coding a time it, to no avail. When I harded coded a time in, I still got the date put in. I would appreciate any help that can be given. The time is going into a LastUpdated field, so there is no user input of the time. Thanks...
×
×
  • Create New...