Please could you see these codes. Its doesnt save on my database. I am not what happen.
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.OleDb;
namespace LunaOffice
{
public partial class RegistrarDemissao : Form
{
public Saveagent()
{
InitializeComponent();
}
OleDbConnection conn;
OleDbCommand comm;
string connstr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\office\office\\app_data\office.mdb;Persist Security Info=False";
private void btnSaveCompany_Click(object sender, EventArgs e)
{
conn = new OleDbConnection(connstr);
comm = new OleDbCommand();
conn.Open();
OleDbParameter name = new OleDbParameter("@nam", SqlDbType.VarChar);
comm.Parameters.Add(name);
funcionario.Value = cbxName.Text;
comm.Connection = conn;
comm.CommandText = "insert into Full_Company values(@nam)";
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Saved...");
}
catch (Exception)
{
MessageBox.Show("Not Saved...");
}
finally
{
conn.Close();
}
}
VulpesPosted Oct 13, 2014, 5:42 AM
Mfwamba TshimangaPosted Oct 13, 2014, 6:00 PM
Mfwamba TshimangaPosted Oct 13, 2014, 4:22 AM
Riddhi ValechaPosted Oct 13, 2014, 1:21 AM
You are missing the lines -
comm.CommandType = CommandType.StoredProcedure;
comm.text = "Stored_Procedure_Name";
comm.parameter.Addwithvalue("@abc",'abc');
-------
You have to say whether you are using a stored procedure or simple query.
------
Wim SturkenboomPosted Oct 13, 2014, 12:35 AM
catch (Exception)
{
MessageBox.Show("Not Saved...");
}
[/quote]
Never hide exceptions; if you don't want the user to see them, log them to file and display the 'tailored' message. Vulpes has shown how to find the error.
VulpesPosted Oct 12, 2014, 5:45 PM
Mfwamba TshimangaPosted Oct 12, 2014, 5:38 PM
Its shown this message: Not saved... That mean its doenst save. I dont know what happen.
VulpesPosted Oct 12, 2014, 4:46 PM