水晶报表的sql查询需要编程帮助

时间:2019-04-26 00:37:34

标签: c# asp.net crystal-reports

我需要知道如何使用该SQL查询生成水晶报表,我想制作一张简单的预订发票。

SqlConnection cnn;
    string connectionString = null;
    string sql = null;

    connectionString = @"Server=DESKTOP- 
     8JJO9NL\SQLEXPRESS;Database=HMS;Trusted_Connection=True";
    cnn = new SqlConnection(connectionString);
    cnn.Open();

    SqlCommand myCmd = new SqlCommand();
    myCmd.Connection = cnn;
    myCmd.CommandText = "SELECT 
    customername,contact,arrivaldate,departure,Room#,stayingdays,[[Total 
    amount] from Roomsdata where reservationID=@re ";
    myCmd.Parameters.AddWithValue("@re",TextBox3);
    sql =Convert.ToString(myCmd) ;

    SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);

    DataSet2 ds = new DataSet2();
    dscmd.Fill(ds, "Roomsdata");
    DataTable dt = ds.Tables["Roomsdata"];
    if (dt.Rows.Count == 0)
    {
        Label2.Text="no data found";
        Label2.Visible = true;

    }

0 个答案:

没有答案