Click here to Skip to main content
15,914,322 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Kumar!26-Jun-07 19:18
Kumar!26-Jun-07 19:18 
GeneralRe: Help From Visul Basic And Access 2002 Pin
leckey27-Jun-07 3:05
leckey27-Jun-07 3:05 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Kumar!27-Jun-07 3:53
Kumar!27-Jun-07 3:53 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Dave Kreskowiak27-Jun-07 11:49
mveDave Kreskowiak27-Jun-07 11:49 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Kumar!27-Jun-07 18:34
Kumar!27-Jun-07 18:34 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Dave Kreskowiak27-Jun-07 3:42
mveDave Kreskowiak27-Jun-07 3:42 
GeneralRe: Help From Visul Basic And Access 2002 Pin
Kumar!27-Jun-07 3:54
Kumar!27-Jun-07 3:54 
QuestionQueries on Shared Method Pin
Yenyen Suwardy26-Jun-07 17:57
Yenyen Suwardy26-Jun-07 17:57 
Hi everyone,

I basically understand the functionality of shared methods, however I would like to ask if shared method could be the cause of the situation that I am facing now.

This is an ASP .Net/VB .Net application. I have a class called DataEntry, here I also have the properties of data entry, and a shared method GetLastDataEntry, which gets the last data entry from the db using the specified where condition, and put it in a DataEntry object and return the object.

Public Shared Function GetLastDataEntry(strCondition as String) as DataEntry<br />
  Dim obj as DataEntry<br />
  Dim sql as String<br />
<br />
  sql = "SELECT * FROM tDataEntry"<br />
  If strCondition <> "" Then<br />
    sql &= " WHERE " & strCondition<br />
  End IF<br />
<br />
  sql &= " ORDER BY DateTime DESC"<br />
<br />
  ' The sql result will be put into obj here.<br />
<br />
  return obj<br />
End Function<br />


On a page, I have the following lines of codes:

Dim objDataEntry as DataEntry<br />
<br />
objDataEntry = DataEntry.GetLastDataEntry("Respiration <> 0")<br />
' "Respiration <> 0" is used for the where clause in GetLastDataEntry.<br />
<br />
' Processing for objDataEntry goes here...<br />
<br />
objDataEntry = DataEntry.GetLastDataEntry("Pain <> 0")<br />
' Here, "Pain <> 0" is used for where clause.<br />
<br />
' Processing for objDataEntry goes again...


The above code is correct in syntax. However, when the page is run, typically on more than 1 pc, I will get an sql exception because of the following sql statement:

Incorrect syntax near keyword WHERE. SQL: "SELECT * FROM tDataEntry WHERE Pain <> 0 ORDER BY DateTime DESC WHERE Respiration <> 0 ORDER BY DateTime DESC"

I wonder if the above is because of the shared method, since it is a class method, somehow the previous strCondition that I passed in is still there. But then again, according to the exception caught, Pain comes in first, then Respiration, whereas on the page, Respiration is called first, Pain latter. But then again, not sure if this is caused by the calling from two different PCs.

Please advice if you have any opinion on this. Appreciate!

Cheers!
Yenyen
AnswerRe: Queries on Shared Method Pin
Christian Graus26-Jun-07 18:04
protectorChristian Graus26-Jun-07 18:04 
GeneralRe: Queries on Shared Method Pin
Yenyen Suwardy26-Jun-07 18:13
Yenyen Suwardy26-Jun-07 18:13 
GeneralRe: Queries on Shared Method Pin
Christian Graus26-Jun-07 18:58
protectorChristian Graus26-Jun-07 18:58 
AnswerRe: Queries on Shared Method Pin
Navneet Hegde26-Jun-07 19:21
Navneet Hegde26-Jun-07 19:21 
GeneralRe: Queries on Shared Method Pin
Christian Graus26-Jun-07 20:19
protectorChristian Graus26-Jun-07 20:19 
AnswerRe: Queries on Shared Method Pin
Yenyen Suwardy26-Jun-07 20:20
Yenyen Suwardy26-Jun-07 20:20 
Questionadd form into tab control Pin
Phan Van Thao26-Jun-07 17:15
Phan Van Thao26-Jun-07 17:15 
AnswerRe: add form into tab control Pin
Christian Graus26-Jun-07 17:48
protectorChristian Graus26-Jun-07 17:48 
AnswerRe: add form into tab control Pin
Phan Van Thao26-Jun-07 22:34
Phan Van Thao26-Jun-07 22:34 
QuestionSilly question about calling classes... Pin
commieJerk26-Jun-07 15:27
commieJerk26-Jun-07 15:27 
AnswerRe: Silly question about calling classes... Pin
Christian Graus26-Jun-07 15:42
protectorChristian Graus26-Jun-07 15:42 
GeneralRe: Silly question about calling classes... Pin
commieJerk26-Jun-07 16:32
commieJerk26-Jun-07 16:32 
GeneralRe: Silly question about calling classes... Pin
Christian Graus26-Jun-07 17:47
protectorChristian Graus26-Jun-07 17:47 
GeneralRe: Silly question about calling classes... Pin
commieJerk27-Jun-07 1:43
commieJerk27-Jun-07 1:43 
GeneralRe: Silly question about calling classes... Pin
commieJerk27-Jun-07 1:51
commieJerk27-Jun-07 1:51 
AnswerRe: Silly question about calling classes... Pin
commieJerk28-Jun-07 10:33
commieJerk28-Jun-07 10:33 
Questioncheck if the date given is within the specific range please help... Pin
cutequencher26-Jun-07 14:32
cutequencher26-Jun-07 14:32 

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.