Israel

Israel

  • 701
  • 1.3k
  • 215.8k

Just a convertion Sql atabase to Access Database

Sep 7 2014 11:50 AM

Hi!


I need a big help in correcting my code. I am working with a sql database. Please anyone can convert this code to work with MsAccess Database please.


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.SqlClient;

using System.Globalization;

namespace LunaOffice

{

   public partial class Facturacao : Form

    {

        frmRptFactuVenda facturavenda;

        public Facturacao()

        {

            InitializeComponent();

        }

        SqlConnection conn;

        SqlCommand comm;        

        string connstr = "Data Source=localhost\\sqlexpress;Initial Catalog=master;Integrated Security=True";

        private void btnGravar_Facturacao_Click(object sender, EventArgs e)

        {

            {

                conn = new SqlConnection(connstr);

                comm = new SqlCommand();

                conn.Open();

                SqlParameter data = new SqlParameter("@datafact", SqlDbType.Date);               

                SqlParameter nomecliente = new SqlParameter("@nc", SqlDbType.NChar);

                SqlParameter designacao = new SqlParameter("@desig", SqlDbType.NChar);   

                comm.Parameters.Add(data);

                comm.Parameters.Add(nomecliente);

                comm.Parameters.Add(designacao);

                data.Value = DateTime.Today;               

                nomecliente.Value = nomeClienteFactu.Text;

                designacao.Value = artigoFactu.Text;               

                comm.Connection = conn;                           

                comm.CommandText = "insert into facturacao1 values(@datafact,@nc,@desig)";

                comm.ExecuteNonQuery();

                comm.CommandText = "select * from facturacao1;

  SqlDataReader read = comm.ExecuteReader();

  { 

  read.Close();

  conn.Close();      

  }

 }

Answers (4)