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
Ashish Kalmegh
NA
3
0
Getting Syntax error while executing the INSERT INTO query
Mar 27 2009 5:30 PM
public void button2_Click_1(object sender, EventArgs e)
{
if (textBox1.Text == "")
MessageBox.Show("Select an application to run");
else
{
if (cmbhr.SelectedIndex == -1 || cmbmin.SelectedIndex == -1 || cmbtime.SelectedIndex == -1)
MessageBox.Show("Select proper time format HH:MM:AM/PM");
else
{
//generate the time string from the selected values of HH:MM AM/PM
s = cmbhr.SelectedItem.ToString() + ":" + cmbmin.SelectedItem.ToString() + " " + cmbtime.SelectedItem.ToString();
MessageBox.Show(s);
//SMTimberDB() start ;// Call database function
try
{
mycon.Open();
MessageBox.Show("mycon.Open();");
command1 = string.Format("Insert into STable(Date,Time,Program) VALUES('" + Selected_Date + "','" + s + "','" + filepath + "')");
MessageBox.Show("Insert into STable(Date,Time,Program");
cmdIns = new OleDbCommand(command1, mycon);
MessageBox.Show("cmdIns = new OleDbCommand(command1, mycon);");
//for (int xt = 0; xt < d.stl; xt++)
//{
// string ntime = d.sds.Tables["STable"].Rows[xt]["Time"].ToString();
// if (ntime == s)
// {
// MessageBox.Show("Time already in use !! ");
// break;
// }
//}
cmdIns.Connection = mycon;
MessageBox.Show("cmdIns.Connection = mycon;");
cmdIns.CommandText = command1;
MessageBox.Show("cmdIns.CommandText = command1;");
int xx = cmdIns.ExecuteNonQuery();
string number = xx.ToString();
MessageBox.Show(number);
if (xx > 0)
{
MessageBox.Show("Scheduler Added !! ");
}
MessageBox.Show("Add new sheduler");
}
catch (InvalidOperationException)
{
MessageBox.Show("Request can not be completed due to SQL statement error");
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
// Message not required
}
finally
{
//mycon.Close();
}
//SMTimberDB() end
}
}
Reply
Answers (
1
)
Registry Edit By c# on Vista OS problem
Listbox items in WPF: strange behaviour