hello;
I have a problem using console application.I mostly use Windows application. I m using C# 2005 and Sql server2005 as part of my project.I am using 3layered architecture i have method in Business class:
public static int DataSelectionForAutoGeneratedMsg(string strTableName, out List strContactNos)
Because i have to check that if a customer has his reservation booked for next day then he should be reminded for that.For that our service (which i m intended to built using console app) keep checking in the reservation table having columns(custid,reservationdate,service_name) .!--removed tag-->
then if the result of the query is correct i.e if it returns datatable then it has to send sms to that customer.Below is the code but i have not included the coding for sending sms here.Instead of that i have just used the Console.Writeline statement so that atlaest this par works
also i have not included the coding of internal class ConnectionString
Hope the information will be enough for u to understand
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;
using System.Data.SqlClient;
using HRCF.BL;// adding Business logic
using HRCF.DB;//adding database
using System.ComponentModel;
namespace ConsoleApp_service
{
public class services
{
//private CHRCFDB m_objCHRCFDB = null;
public services()
{
//m_objCHRCFDB = new CHRCFDB();
}
static void Main(string[] args)
{
Console.WriteLine("it is reading this line");
//I dont kno whether the following line of cde is correct
string result = CheckingReservation("reservation", out dtTableRecords_out);
}
public static string CheckingReservation(string strTableName, out DataTable dtTableRecords_out)
{
string strQueryString = "";
SqlCommand objSqlCommand = null;
SqlConnection objSqlConnection = null;
DataSet objDataSet = null;
SqlDataAdapter objDataAdapter = null;
// to check from the current date
string ritenow = Convert.ToString(System.DateTime.Now);
try
{
objDataSet = new DataSet();
objDataAdapter = new SqlDataAdapter();
objSqlConnection = new SqlConnection(ConnectionString.GetSQLConnectionString());
strQueryString = "select cust_id,ser_name from reservation where date = " + ritenow;
objSqlCommand = new SqlCommand(strQueryString, objSqlConnection);
objDataAdapter.SelectCommand = objSqlCommand;
objSqlConnection.Open();
objDataSet.Clear();
objDataAdapter.Fill(objDataSet);
objSqlConnection.Close();
dtTableRecords_out = objDataSet.Tables[0];
if (dtTableRecords_out != null)
{
Console.WriteLine("Service is reserved for today");
}
else
{
Console.WriteLine("No reservation for today");
}
}
finally
{
if (objSqlConnection.State == ConnectionState.Open)
{
objSqlConnection.Close();
}
}
return strQueryString;
}
}
}
I am unable to find any error.When i debug it then nothing happens no black window instead of it an empty form appears.
!--removed tag-->
Enter your message below
Sign in or Join us (it's free).