Quantcast
Channel: SharpDevelop Community
Viewing all articles
Browse latest Browse all 1764

Report with db Ms access

$
0
0

Hello,

I want to do a report with ms access but i can not do, this is code to create xsd file:
I use the wizard Report and in "ReportSettings"  use: ReportType: 'DataReport' and DataModel: 'PushData', I do not understand the next step...

thanks!!!

using System;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Xml;
using ICSharpCode;


namespace myApp
{
    /// <summary>
    /// Description of Class1.
    /// </summary>
    /// 
    
    public class CreaXml
    {
        OleDbConnection Cn = null;
        public CreaXml()
        {
            InizializeDB();
            LeggoDb();

        }
        OleDbConnection InizializeDB()
        {
        String connVal = null;
        String perCorso = null;
        String connString = null;
        try
        {            
            connString = ConfigurationManager.ConnectionStrings["connectionString"].ToString();
            
            try
            {
            Cn = new OleDbConnection(connString);
            try {
                Cn.Open();
               // MessageBox.Show(Cn.State.ToString()+" : Db Centralino");
                
            } catch (SqlException ex) {
                 
                 MessageBox.Show(ex.ToString()," ATTENZIONE ",MessageBoxButtons.OK ,MessageBoxIcon.Stop);
                 return null;
            }
            
            }
            catch(Exception ex)
            {
                MessageBox.Show("ERRORE: Db non trovato" + connString," ATTENZIONE ",MessageBoxButtons.OK ,MessageBoxIcon.Stop);
                return null;
            }
        }
        catch
        {
            // se la chiave non esiste...
            MessageBox.Show("ERRORE: File configurazione non trovato " + connString," ATTENZIONE ",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
            return null;
        }
        Cn.Close();
        return Cn;
        }
        void LeggoDb()
        {
        OleDbDataAdapter dd = null;
        OleDbCommandBuilder dc = null;
        DataTable dt = null;
        //BindingSource bs = null;
        
        string sqlSelect = "SELECT * FROM SPEDIZIONE";
        try {
            
        dd = new OleDbDataAdapter(sqlSelect,Cn);
        dc = new OleDbCommandBuilder(dd);
        dt = new DataTable();
        dt.TableName = "SPEDIZIONE";
        dd.Fill(dt);
        //
        System.IO.FileStream filestream = new System.IO.FileStream("filename.xsd", System.IO.FileMode.Create);
        XmlTextWriter xmlwriter = new XmlTextWriter(filestream, System.Text.Encoding.UTF8);
        xmlwriter.WriteStartDocument(true);
        dt.WriteXml(xmlwriter, XmlWriteMode.WriteSchema);
        xmlwriter.Close();
        } catch (Exception ex) {
            
            MessageBox.Show(" ERRORE: "+ ex.ToString()," ATTENZIONE ",MessageBoxButtons.OK,MessageBoxIcon.Stop);
        }
        
        }
    }
}


Viewing all articles
Browse latest Browse all 1764

Trending Articles