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
693
1.3k
219.5k
Show me the last record after saving and on time....
Jul 10 2014 9:34 AM
Hi!
These codes allow me to save without problem.
But what I want to know it's after saving my record. I would like to see the latest record (only one culumn as I specify in my code) appear on my label just AFTER SAVING and ON TIME.
Please have a look:
private void btnGravar_Facturacao_Click(object sender, EventArgs e)
{
{
conn = new SqlConnection(connstr);
comm = new SqlCommand();
conn.Open();
SqlParameter numberprint = new SqlParameter("@numberprint", SqlDbType.NChar);
SqlParameter data = new SqlParameter("@datafact", SqlDbType.Date);
comm.Parameters.Add(numberprint);
comm.Parameters.Add(data);
numberprint.Value = lblNumberprint.Text;
data.Value = DateTime.Today;
comm.Connection = conn;
comm.CommandText = "insert into facturacao1 values(@numberprint,@datafact)";
//////////////////////////////////It's here where I try to write the code to show the latest record saving and every time on time//////////////////
string connectionString = @"Data Source=localhost\sqlexpress;Initial Catalog=master;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
string commandString = "select * from facturacao1 where numberprint ='" + lblNumberprint.Text + "'";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
lblNumberprint.Text = read["numberprint"].ToString();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Saved");
}
catch (Exception)
{
MessageBox.Show("Not saved");
}
finally
{
conn.Close();
}
}
}
}
Reply
Answers (
12
)
Adding items to comboBox at runtime C# windows application
How to use two parameter in Standard Numeric Format Strings