2010-09-15 27 views
0

這是我的代碼部分如何在文本框中插入時間列

//實例我們必須處理 字符串名稱= txtName.Text的對象; string描述= txtDecription.Text; string Topic = txtTopic.Text; string贊助商= txtSponsor.Text; string Location = txtLocation.Text; System.DateTime StartDate; StartDate = DateTime.Parse(txtStartDate.Text); System.DateTime EndDate = DateTime.Parse(txtEndDate.Text); string URL = txtURL.Text;

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

錯誤:Argumnet 6和7 .cannot從系統.DateTime轉換爲「字符串 需要一些幫助

回答

0

簡單你的函數需要字符串參數傳遞你datatime作爲參數,

解決方案1: 更改此聲明

System.DateTime StartDate; StartDate= DateTime.Parse(txtStartDate.Text); 
System.DateTime EndDate = DateTime.Parse(txtEndDate.Text); 

string StartDate= txtStartDate.Text; 
string EndDate = txtEndDate.Text; 

解決方案2: 或同時通過參數轉換DateTime對象,字符串對象

StartDate.ToString() 
EndDate.ToString() 

這麼簡單,

+0

THANKS RAMAKRISHNAN,問題解決 – prince 2010-09-15 12:11:26

0

嘗試:

intResult = pBAL.Insert(Name,Description, Topic,Sponsor, Location,StartDate.ToString(),EndDate.ToString(),URL); 
0

請檢查您的文本框中的日期格式它必須是MM/dd/yy然後它會在日期時間格式中解析t

相關問題