Need help,want to insert record via a webform ,but 2 of are my column data type are DateTime

this is part of my code:

string Name = txtName.Text;
         string Description = txtDecription.Text;
         string Topic = txtTopic.Text;
         string Sponsor = txtSponsor.Text;
         string Location = txtLocation.Text;
         DateTime StartDate;
            StartDate= DateTime.Parse(txtStartDate.Text);
         DateTime EndDate = DateTime.Parse(txtEndDate.Text);
         string URL = txtURL.Text;

         try
         {
            intResult = pBAL.Insert(Name,Description, Topic,Sponsor, Location,StartDate,EndDate, URL);
         }

Error:Cannot Convert from System.'DateTime' to 'string'

There are some possibilities for occuring this error.
1) It may be possible that your pBAL.Insert() accepts StartDate/EndDate as string type but you are passing StartDate/EndDate as DateTime.
2) another thing is you have defined StartDate/EdnDate as string type in database but you are trying to store datetime ..

check this and change it as per your requiremnt and let us know...

Need help,want to insert record via a webform ,but 2 of are my column data type are DateTime

this is part of my code:

     string Name = txtName.Text;
     string Description = txtDecription.Text;
     string Topic = txtTopic.Text;
     string Sponsor = txtSponsor.Text;
     string Location = txtLocation.Text;
     DateTime StartDate;
        StartDate= DateTime.Parse(txtStartDate.Text);
     DateTime EndDate = DateTime.Parse(txtEndDate.Text);
     string URL = txtURL.Text;

     try
     {
        intResult = pBAL.Insert(Name,Description, Topic,Sponsor, Location,StartDate,EndDate, URL);
     }

Error:Cannot Convert from System.'DateTime' to 'string'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.