TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Israel
701
1.3k
215.8k
Want to save date using time system not C# tool date
Apr 30 2014 11:33 AM
Hi!
All these codes work very well. I put all here to give you a good understanding to help me.
I have a table I can save safelly without problem. But I would like to learn how can I among these code to save my current time system directly in the column of my sql table (time of my computer). In other word, if its will mess to much in my code then which value can I for the date.
private void btnSave_Facturacao_Click(object sender, EventArgs e)
{
{
conn = new SqlConnection(connstr);
comm = new SqlCommand();
conn.Open();
SqlParameter S = new SqlParameter("@S", SqlDbType.NChar);
SqlParameter data = new SqlParameter("@dataFact", SqlDbType.Date);
// here
SqlParameter nomecliente = new SqlParameter("@nc", SqlDbType.NChar);
SqlParameter designacao = new SqlParameter("@desig", SqlDbType.NChar);
SqlParameter codigo = new SqlParameter("@cod", SqlDbType.VarChar);
SqlParameter quantidade = new SqlParameter("@quant", SqlDbType.NChar);
SqlParameter precocompra = new SqlParameter("@precocompra", SqlDbType.NChar);
SqlParameter precosaida = new SqlParameter("@precosaida", SqlDbType.NChar);
SqlParameter total = new SqlParameter("@total", SqlDbType.NChar);
SqlParameter lucrovenda = new SqlParameter("@lucrovenda", SqlDbType.NChar);
SqlParameter troco = new SqlParameter("@troco", SqlDbType.NChar);
SqlParameter utilizador = new SqlParameter("@utilizador", SqlDbType.NChar);
comm.Parameters.Add(S);
comm.Parameters.Add(data);
//here
comm.Parameters.Add(nomecliente);
comm.Parameters.Add(designacao);
comm.Parameters.Add(codigo);
comm.Parameters.Add(quantidade);
comm.Parameters.Add(precocompra);
comm.Parameters.Add(precosaida);
comm.Parameters.Add(total);
comm.Parameters.Add(lucrovenda);
comm.Parameters.Add(troco);
comm.Parameters.Add(utilizador);
S.Value = "*";
data.Value = dateTimePicker1.Value;
//here
nomecliente.Value = nomeClienteFactu.Text;
designacao.Value = artigoFactu.Text;
codigo.Value = leituraCodFactu.Text;
quantidade.Value = quantidadeFactu.Text;
precocompra.Value = precocompraFactu.Text;
precosaida.Value = precosaidaFactu.Text;
total.Value = totalFactu.Text;
lucrovenda.Value = lucrovendaFactu.Text;
troco.Value = trocos.Text;
utilizador.Value = utilizadores.Text;
//total.Value = totalFactu.Text;
//lucrovenda.Value =
//troco
//utilizador
comm.Connection = conn;
comm.CommandText = "insert into fact values(@s,@datafact,@nc,@desig,@cod,@quant,@precocompra,@precosaida,@total,@lucrovenda,@troco,@utilizador)";
try
{
comm.ExecuteNonQuery();
MessageBox.Show("saved");
nomeClienteFactu.Clear();
/*artigoFactu.Text = "";
quantidadeFactu.Clear();
precoFactu.Clear();
totalFactu.Clear();*/
}
catch (Exception)
{
MessageBox.Show("Not saved");
}
finally
{
conn.Close();
}
}
}
private void Facturacao_Load(object sender, EventArgs e)
{
}
}
}
Reply
Answers (
8
)
Did youu already proove it? Its works really???
how to show the data in grid view ( or any tool to view)