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);
Abhay ShankerPosted Jun 26, 2014, 10:57 PM
Also check the count of charters you are going to save.
Pankaj BajajPosted Jun 26, 2014, 9:39 PM
1. Check insert Query in sql command is making correct. Check that query in DB.
2. Check what exception is coming.In Message box show Exception.Message(),it will show exact error.
Satyapriya NayakPosted Jun 26, 2014, 2:22 PM