Note that there are some explanatory texts on larger screens.

plurals
  1. POConnecting Calendar control to LINQ database - Visual Studio
    primarykey
    data
    text
    <p>I have 2 calender controls 'cldStartDate' and 'cldEndDate' which link to 2 textboxes 'txtStartDate' and 'txtEndDate. When a date is selected these textboxes hold the dates. I am trying to get my code to add the dates into my database. It has the following fields:</p> <p>-ProjectName -Description -StartDate -EndDate</p> <p>Both 'StartDate' and 'EndDate' are of type DateTime in my database. Could someone please point out where I am going wrong in my code. I think I need to change the code to pass the date values in as DateTime. Has anyone got an idea of how I may do that. The code is below. Thanks!</p> <p>Protected Sub btnAddProject_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddProject.Click</p> <pre><code> Dim projectName As String Dim projectDescription As String Dim startdate As String Dim enddate As String projectName = txtProjectName.Text projectDescription = txtProjectName.Text startdate = txtStartDate.Text enddate = txtEndDate.Text ' check the validity of information entered Dim isValid As Boolean isValid = True If String.IsNullOrEmpty(projectName) Or String.IsNullOrEmpty(projectDescription) Then isValid = False End If If isValid Then 'add everything to the database Dim db As New AgileClassesDataContext() Dim startDate As String startDate = DateTime.Parse(startDate) Dim endDate As String endDate = DateTime.Parse(endDate) ' create a project to populate a row in the PROJECT table Dim project As New Project With _ {.ProjectName = projectName, _ .Description = projectDescription _ .StartDate = startdate _ .EndDate = enddate} ' add the new project to the PROJECT table db.Projects.InsertOnSubmit(project) ' submit the changes to the database Try db.SubmitChanges() Catch ex As Exception Console.WriteLine(ex) db.SubmitChanges() End Try' </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload