hi friends,
string problem in asp.net uing csharp
VB coding is quite running,
but
my problem is How to write charp code in below code
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'string' to 'System.DateTime'
Source Error:
Line 736: DateTime cudate = default(DateTime);
Line 737: DateTime exdate = default(DateTime);
Line 738: cudate = DateTime.Now.ToShortDateString();
Line 739:
In VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim cudate As DateTime
Dim exdate As DateTime
cudate = Now.Date.ToShortDateString
OpenConnection(con)
cmd.Connection = con
cmd.CommandText = "SELECT * from jsreg"
dr = cmd.ExecuteReader()
While dr.Read()
exdate = dr("expdate")
If exdate.CompareTo(cudate) = 0 Then
OpenConnection(con1)
cmd1.Connection = con1
cmd1.CommandText = "delete from jsreg where expdate='" + exdate.ToShortDateString + "'"
cmd1.ExecuteNonQuery()
con1.Close()
Else
End If
End While
con.Close()
End Sub
in CS #
protected void Page_Load(object sender, System.EventArgs e)
{
DateTime cudate = default(DateTime);
DateTime exdate = default(DateTime);
cudate = DateTime.Now.ToShortDateString();
OpenConnection(con);
cmd.Connection = con;
cmd.CommandText = "SELECT * from jsreg";
dr = cmd.ExecuteReader();
while (dr.Read()) {
exdate = dr["expdate"];
if (exdate.CompareTo(cudate) == 0) {
OpenConnection(con1);
cmd1.Connection = con1;
cmd1.CommandText = "delete from jsreg where expdate='" + exdate.ToShortDateString() + "'";
cmd1.ExecuteNonQuery();
con1.Close();
} else {
}
}
con.Close();
}
please correct this c# code.
thanks in advance.