Hi guys i have windows form application in this form i need to show date of server
not date of client so that i write following function
stored procedure
create proc datetoday1
as
select getdate()as datetoday
function in c#
public string GetDateProcesses(string ConnectionString)
{
SqlConnection con = new SqlConnection(ConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "datetoday1";
con.Open();
string getdate=Convert.ToString(cmd.ExecuteNonQuery());
con.Close();
return getdate;
}
in interface
FleetManagment.Fleet fleetAccountNo = new FleetManagment.Fleet();label3.Text = fleetAccountNo.GetDateProcesses("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "");
but it return -1 not date of server what is wrong in my code
and what modification in code to return true result

Shubham KumarRank #621 · 3.8K reputationPosted Apr 9, 2015, 12:24 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted Apr 9, 2015, 12:26 AM EDT
ahmed saRank #8,218 · 226 reputationPosted Apr 9, 2015, 2:33 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted Apr 9, 2015, 5:01 AM EDT
just exexut that you got the answer
ahmed saRank #8,218 · 226 reputationPosted Apr 9, 2015, 5:52 AM EDT
Shubham KumarRank #621 · 3.8K reputationPosted Apr 9, 2015, 8:38 AM EDT
string date;
string str1 = "select GetaDate() as Date'"'";
SqlCommand cmd = new SqlCommand(str1, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())////use while or if which u want
{
date= dr["Date"].ToString() )
}
return date;
i just write this but an not debug it so please debug it
Shubham KumarRank #621 · 3.8K reputationPosted Apr 9, 2015, 8:40 AM EDT