Abdelaziz Omar

Abdelaziz Omar

  • NA
  • 2
  • 1.5k

how to run a SQL stored procedure from C# at a specificTime

Apr 20 2016 4:10 PM

Guys now I need to know how to run a SQL stored procedure from through C# at a specific time. Any help please? ...


the user will the query in Query Tab and the time in Execute Time Tab i need the program execute the query By ID in the time which the user put it in the Column Execute Time

My codes is but this execute the query From textbox i need to make it execute the query by id which time the user put it in Table ExecQuery

my codeS:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Execute_Click(object sender, EventArgs e)
{
SqlConnection sql = new SqlConnection("Data Source=" + this.Host.Text + ";Initial Catalog=" + this.Database.Text + ";Integrated Security=false; User ID = " + this.HostUser.Text + "; Password = " + this.HostPw.Text + ";MultipleActiveResultSets=true;");
try
{
sql.Open();
try
{
new SqlCommand(this.Query.Text, sql).ExecuteNonQuery();
MessageBox.Show("Query executed.", "Success");
}
catch
{
MessageBox.Show("Invalid query.", "Query Error");
}
sql.Close();
}
catch
{
MessageBox.Show("Error with sql connection, try with a correct sql informations.", "Error");
}
}
}
}
 

Answers (1)