Click here to Skip to main content
15,898,769 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing values between classes Pin
Pete O'Hanlon1-Mar-12 11:29
mvePete O'Hanlon1-Mar-12 11:29 
GeneralRe: Passing values between classes Pin
BobJanova1-Mar-12 23:31
BobJanova1-Mar-12 23:31 
QuestionCan't create Workflow projects? Pin
SledgeHammer0129-Feb-12 6:39
SledgeHammer0129-Feb-12 6:39 
AnswerRe: Can't create Workflow projects? Pin
Richard MacCutchan29-Feb-12 7:14
mveRichard MacCutchan29-Feb-12 7:14 
QuestionGet Namespaces and/or Assemblies In A Solution Pin
Kevin Marois29-Feb-12 6:05
professionalKevin Marois29-Feb-12 6:05 
AnswerRe: Get Namespaces and/or Assemblies In A Solution Pin
Pete O'Hanlon29-Feb-12 6:14
mvePete O'Hanlon29-Feb-12 6:14 
AnswerRe: Get Namespaces and/or Assemblies In A Solution Pin
Ennis Ray Lynch, Jr.29-Feb-12 6:15
Ennis Ray Lynch, Jr.29-Feb-12 6:15 
QuestionCorrection needed in SQL Query Pin
Abdul Anoop29-Feb-12 5:45
Abdul Anoop29-Feb-12 5:45 
Guys,

Am trying to access the data from SQL SERVER 2008 via C#. I am getting an Exception. I am sure that I have problem with the query. please check this and reply...

The Code is:

private SqlDataReader GetInContainers(DateTime tFromDate,DateTime tToDate)
{
SqlConnection mycon = new SqlConnection(@"server=XYZ ; database = ABC; Trusted_Connection=yes");
mycon.Open();
string sql="Select CntNo, iso_code, InDateTime from gatein_containers where (InDateTime between #" + tFromDate.ToString("MM/dd/yyyy HH:mm:ss") + "# and #" + tToDate.ToString("MM/dd/yyyy HH:mm:ss") + "#) " +
" and (SHIPPING_LINE_CODE='1' or SHIPPING_LINE_CODE='MSL') order by InDateTime";


MessageBox.Show("Going to Execute");


SqlCommand myCommand = new SqlCommand(sql, mycon);
myReader = myCommand.ExecuteReader();
mycon.Close();
mycon.Dispose();
MessageBox.Show("Executed");
return myReader;


}

I am able to get the result when I use simple querty like:
sql="select * from daily;
AnswerRe: Correction needed in SQL Query Pin
Pete O'Hanlon29-Feb-12 5:50
mvePete O'Hanlon29-Feb-12 5:50 
AnswerRe: Correction needed in SQL Query Pin
Shameel29-Feb-12 8:05
professionalShameel29-Feb-12 8:05 
QuestionEmail button in Datagridview Pin
pmcm29-Feb-12 5:38
pmcm29-Feb-12 5:38 
AnswerRe: Email button in Datagridview Pin
Montasser Ben Ouhida2-Mar-12 4:48
Montasser Ben Ouhida2-Mar-12 4:48 
GeneralRe: Email button in Datagridview Pin
pmcm4-Mar-12 22:23
pmcm4-Mar-12 22:23 
AnswerRe: Email button in Datagridview Pin
satalaj2-Mar-12 5:23
satalaj2-Mar-12 5:23 
GeneralRe: Email button in Datagridview Pin
pmcm4-Mar-12 22:29
pmcm4-Mar-12 22:29 
QuestionFiltering excel Application Pin
polachan28-Feb-12 23:48
polachan28-Feb-12 23:48 
AnswerRe: Filtering excel Application Pin
Not Active29-Feb-12 1:10
mentorNot Active29-Feb-12 1:10 
AnswerRe: Filtering excel Application Pin
Shameel29-Feb-12 4:05
professionalShameel29-Feb-12 4:05 
QuestionLimiting Users Download Size Pin
Majid Shahabfar28-Feb-12 21:14
Majid Shahabfar28-Feb-12 21:14 
AnswerRe: Limiting Users Download Size Pin
Pete O'Hanlon28-Feb-12 21:35
mvePete O'Hanlon28-Feb-12 21:35 
GeneralRe: Limiting Users Download Size Pin
Majid Shahabfar29-Feb-12 0:53
Majid Shahabfar29-Feb-12 0:53 
GeneralRe: Limiting Users Download Size Pin
Pete O'Hanlon29-Feb-12 0:58
mvePete O'Hanlon29-Feb-12 0:58 
GeneralRe: Limiting Users Download Size Pin
Majid Shahabfar29-Feb-12 8:41
Majid Shahabfar29-Feb-12 8:41 
GeneralRe: Limiting Users Download Size Pin
Pete O'Hanlon29-Feb-12 8:53
mvePete O'Hanlon29-Feb-12 8:53 
GeneralRe: Limiting Users Download Size Pin
Majid Shahabfar29-Feb-12 21:19
Majid Shahabfar29-Feb-12 21:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.