OdbcConnection conn;
string connStr = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=report;" + "UID=root;" + "PASSWORD=7200581;" + "OPTION=3"; conn = new OdbcConnection(connStr); conn.Open();
report = new CrystalReport1(); OdbcCommand cmd = conn.CreateCommand(); //cmd.CommandText = "select * from wendu where id = 1"; cmd.CommandText = query; OdbcDataAdapter da = new OdbcDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, "wendu"); report.SetDataSource(ds); crystalReportViewer1.ReportSource = report; //move conn.Close();