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
anbu
NA
3
1.9k
C# and SQL question
Nov 12 2011 5:27 AM
Hello to everyone! I have one problem and don't know how to solve it so I need your help. I'm building a very simple application to insert text values into a database.
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=BADRINATH-PC\SQLEXPRESS;Initial Catalog=Vremenik;Integrated Security=True;User Instance=False;");
try
{
SqlCommand cmd = new SqlCommand("INSERT INTO dbo.profesori(Ime,Prezime,VrstaProvjere,DatumProvjere) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "','" + comboBox1.Text + "', '" + dateTimePicker1.Value.Date + "')", conn);
conn.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Connection Succeful");
}
catch (SqlException ex)
{
MessageBox.Show("There is an Error" + ex);
}
finally
{
conn.Close();
MessageBox.Show("Connection Closed");
}
}
The problem is that I don't know how to check how many times is one value inserted into the specific column of the table? What to do for example if I don't want to have two same dates in my Date column? How can I solve this problem?
Reply
Answers (
2
)
How to make a search textbox in c#
Help with "Input string was not in a correct format" error