Israel

Israel

  • 659
  • 1.3k
  • 206.3k

All the day without saving another column...

Jun 26 2014 1:45 PM
Hi!
 
There is a something I didnt understand... I passed all the day for that.
 
I have a table named fact1 with two column
column name                       datatype      Allows null
S                                          nchar(10)
Designacao                         nchar(10)        
 
Now with these codes I can save. There is n problem.
 
 
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;
namespace LunaOffice
{
public partial class Facturacao : Form
{
public Facturacao()
{
InitializeComponent();
}
SqlConnection conn;
SqlCommand comm;
//SqlDataReader dreader;
string connstring = @"Data Source=inac-pc\sqlexpress;Initial Catalog=master;Integrated Security=True";
private void btnGravar_Facturacao_Click(object sender, EventArgs e)
{
conn = new SqlConnection(connstring);
conn.Open();
comm = new SqlCommand("insert into fact1 values(" + symb.Text + ",'" + artigoFactu.Text + "')", conn);
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Saved...");
}
catch (Exception)
{
MessageBox.Show("Not Saved");
}
finally
{
conn.Close();
}
 
But when I add another column for example "codigo" with same datatype "nchar(10)".
When I click its says "Not saved". What wrong???????  I passed all the day just without solution.
 see what I add. But nothing:
 comm = new SqlCommand("insert into fact1 values(" + symb.Text + ",'" + artigoFactu.Text + "'," + leituraCodFactu.Text + "')", conn); 
 
 

Answers (3)