C# VS 2015 프로그램에서 작업 중입니다. 내 프로그램에서 특정 버튼을 클릭하여 작업 수행 중임을 알리는 메시지를 생성하는 큰 텍스트 표시 상자가 있습니다.SQL 서버에서 프로그램으로 행 수 표시
어쨌든 일부 테이블에는 COUNT
에 대한 쿼리가있는 SQL 스크립트가 있습니다. 내 프로그램을 통해 그 스크립트를 실행할 수 있습니다. 그러나 행 수는 테이블에 대한 총 행 수를 표시하며 SQL 서버 내에서만 볼 수 있습니다. 내 스크립트를 실행하고 큰 텍스트 디스플레이 박스에서 내 프로그램 내에 ROW COUNTS를 표시하는 방법이 있는지 궁금합니다. 여기
/* open sql connection to execute SQL script: Row count script*/
try
{
using (SqlConnection con = new SqlConnection(constr))
{
con.Open();
FileInfo file = new FileInfo(DIRECTORY OF THE SCRIPT);
string script = file.OpenText().ReadToEnd();
Server server = new Server(new ServerConnection(con));
server.ConnectionContext.ExecuteNonQuery(script);
Display("ABCDG"); -- to display message on text display
con.Close();
}
}
catch (Exception ex)
{
textBox1.AppendText(string.Format("{0}", Environment.NewLine));
textBox1.AppendText(string.Format("{0} MainPage_Load() exception - {1}{2}", _strThisAppName, ex.Message, Environment.NewLine));
Display(ex.Message + ""); -- display message to textbox
textBox1.AppendText(string.Format("{0}", Environment.NewLine));
Debug.WriteLine(string.Format("{0} MainPage_Load() exception - {1}", _strThisAppName, ex.Message));
}
내 프로그램의 스냅 샷입니다 : 여기
는 SQL 스크립트를 실행하려면 코드의 조각입니다 테츠야 야마모토 당신이 무엇인지, 자신의 의견에 말했듯이
https://i.stack.imgur.com/uKP99.png
와'ExecuteNonQuery는 (스크립트)에서 스크립트 것입니다;'은? – derloopkat
스크립트는 행 수 목록을 포함합니다. 예를 들어 표 A에서 개수 (*)를 선택하고 표 B에서 개수 (*)를 선택하십시오. –
A_Name_Does_Not_Matter이를 수행하는 방법을 명확히 할 수 있습니까? –