I am getting an error message as 'Incorrect Syntax near the keyword UNION.
The target site is -
Void ProcessResults(System.Data.OleDb.OleDbHResult)
and the stacktrace is as follows:-
at System.Data.OleDb.OleDbDataReader.ProcessResults(OleDbHResult hr) at System.Data.OleDb.OleDbDataReader.NextResult() at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at MFActivityPlanning.NewStuffS.PopulateNewStuffsDataGrid()
The query is as follows:
strSelectQuery = "SELECT LED_ID AS PK_ID, FIRST_NAME + ' ' + LAST_NAME AS NAME"
+ " FROM M_LEADERLED INNER JOIN M_USER_DETAILS"
+ " ON M_LEADERLED.LED_ID = M_USER_DETAILS.PK_ID"
+ " WHERE (M_LEADERLED.LEADER_ID = " + Session["UserID"].ToString() + ""
+ " AND M_USER_DETAILS.ACTIVE = 1 AND M_LEADERLED.START_DATE <= Getdate()"
+ " AND M_LEADERLED.END_DATE > Getdate())"
+ " UNION SELECT PK_ID, FIRST_NAME + ' ' + LAST_NAME AS NAME"
+ " FROM M_USER_DETAILS WHERE PK_ID = " + Session["UserID"].ToString() + ";";
// Query for Idea
string selectIdea = "SELECT MWL.PK_ID AS PK_ID, 'Idea'+ ': ' + MI.TITLE AS TITLE,"
+ " 'Idea.aspx?id=' + CONVERT(VARCHAR, MI.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_IDEAS MI ON MWL.FK_OBJECT_ID = MI.PK_ID"
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Idea) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1";
// Query for Articles
string selectArticle = "SELECT MWL.PK_ID AS PK_ID, 'Articles' + ': ' + MA.TITLE AS TITLE,"
+ " 'Articles.aspx?id=' + CONVERT(VARCHAR, MA.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_ARTICLES MA ON MWL.FK_OBJECT_ID = MA.PK_ID"
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Article) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MA.IS_ACTIVE = 1";
// Query for Tips
string selectTips = "SELECT MWL.PK_ID AS PK_ID, 'Tips' + ': ' + MT.TITLE AS TITLE,"
+ " 'Tips.aspx?id=' + CONVERT(VARCHAR, MT.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_TIPS MT ON MWL.FK_OBJECT_ID = MT.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Tip) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MT.IS_ACTIVE = 1";
// Query for IWantINeed
string selectIWantINeed = "SELECT MWL.PK_ID AS PK_ID, 'IWantINeed' + ': ' + MWN.TITLE AS TITLE,"
+ " 'IWantINeed.aspx?id=' + CONVERT(VARCHAR, MWN.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_I_WANT_I_NEED MWN ON MWL.FK_OBJECT_ID = MWN.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.IWantINeed) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1";
// Query for PointCAT
string selectPointCAT = "SELECT MWL.PK_ID AS PK_ID, 'PointCAT' + ': ' + MPS.TITLE AS TITLE,"
+ " 'PointCAT.aspx?id=' + CONVERT(VARCHAR, MPS.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_POINTCAT_SESSIONS MPS ON MWL.FK_OBJECT_ID = MPS.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.PointCAT) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MPS.IS_ACTIVE = 1";
// Query for Seminar
string selectSeminar = "SELECT MWL.PK_ID AS PK_ID, 'Seminar' + ': ' + MS.TITLE AS TITLE,"
+ " 'Seminar.aspx?id=' + CONVERT(VARCHAR, MS.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_SEMINAR MS ON MWL.FK_OBJECT_ID = MS.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Seminar) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MS.IS_ACTIVE = 1";
// Query for CodeCAT
string selectCodeCAT = "SELECT DISTINCT MWL.PK_ID AS PK_ID, 'Code Review Feedback:"
+ " ' + MUD1.FIRST_NAME + ' ' + MUD1.LAST_NAME AS TITLE,"
+ " 'CodeCatFeedback.aspx?id=' + CONVERT(VARCHAR, MCS.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_CODECAT_SESSIONS MCS ON MWL.FK_OBJECT_ID = MCS.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " INNER JOIN M_USER_DETAILS MUD1 ON MUD1.PK_ID = MCS.REVIEW_MEMBER"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.CodeCatFeedback) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MCS.ACTIVE = 1";
// Query for NowShowing
string selectNowShowing = "SELECT MWL.PK_ID AS PK_ID, 'NowShowing' + ': ' + MNS.TITLE AS TITLE,"
+ " 'NowShowing.aspx?id=' + CONVERT(VARCHAR, MNS.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_NOW_SHOWING MNS ON MWL.FK_OBJECT_ID = MNS.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.NowShowing) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MNS.IS_ACTIVE = 1";
// Query for QA
string selectQA = "SELECT MWL.PK_ID AS PK_ID, 'Q&A' + ': ' + MQ.TITLE AS TITLE,"
+ " 'QA.aspx?id=' + CONVERT(VARCHAR, MQ.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_QA MQ ON MWL.FK_OBJECT_ID = MQ.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.QA) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MQ.IS_ACTIVE = 1";
// Query for Message
string selectMessage = "SELECT MWL.PK_ID AS PK_ID, 'Message' + ': ' + MS.SUBJECT AS TITLE,"
+ " 'Message.aspx?id=' + CONVERT(VARCHAR, MS.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_MESSAGE MS ON MWL.FK_OBJECT_ID = MS.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Message) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MS.IS_ACTIVE = 1";
// Query for Documents
string selectDocuments = "SELECT MWL.PK_ID AS PK_ID, 'Documents' + ': ' + MSV.TITLE AS TITLE,"
+ " 'Document.aspx?id=' + CONVERT(VARCHAR, MSD.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_SHARE_DOCUMENT MSD ON MWL.FK_OBJECT_ID = MSD.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " INNER JOIN M_SHARE_DOC_VERSION MSV ON MSV.FK_DOC_ID = MSD.PK_ID AND MSV.IS_ACTIVE =1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Document) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MSD.IS_ACTIVE = 1";
// Query for Candidate
string selectCandidate = "SELECT MWL.PK_ID AS PK_ID, 'Candidate' + ': ' + MC.CAND_NAME AS TITLE,"
+ " 'Candidates.aspx?id=' + CONVERT(VARCHAR, MC.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_CANDIDATE MC ON MWL.FK_OBJECT_ID = MC.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Candidate) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1";
// Query for Prospect
string selectProspect = "SELECT MWL.PK_ID AS PK_ID, 'Prospect' + ': ' + MP.PROSPECT_NAME AS TITLE,"
+ " 'Prospect2.aspx?id=' + CONVERT(VARCHAR, MP.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_PROSPECT MP ON MWL.FK_OBJECT_ID = MP.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.Prospect) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1";
// Query for ToolCAT
string selectToolCAT = "SELECT MWL.PK_ID AS PK_ID, 'ToolCAT' + ': ' + MT.TOOL_NAME AS TITLE,"
+ " 'Catalyst/ToolCAT.aspx?id=' + CONVERT(VARCHAR, MT.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN M_TOOLCAT MT ON MWL.FK_OBJECT_ID = MT.PK_ID "
+ " INNER JOIN M_USER_DETAILS MUD ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = " + Convert.ToInt32(WatchType.ToolCAT) + ""
+ " AND MWL.FK_USER_ID = " + userId + " AND MWL.IS_ACTIVE = 1 AND MT.IS_ACTIVE = 1";
string selectLearningMatter = "SELECT DISTINCT MWL.PK_ID AS PK_ID, 'Learning Matter: ' + KMLM.TITLE AS TITLE,"
+ " 'KLMS/LearningMatterView.aspx?id=' + CONVERT(VARCHAR, KMLM.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN KLMS_M_LEARNING_MATTER KMLM"
+ " ON MWL.FK_OBJECT_ID = KMLM.PK_ID INNER JOIN M_USER_DETAILS MUD"
+ " ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = 505 AND MWL.FK_USER_ID = " + userId + " AND"
+ " MWL.IS_ACTIVE = 1 AND KMLM.IS_ACTIVE = 1";
// Query for Questions
string selectQuestions = "SELECT DISTINCT MWL.PK_ID AS PK_ID, 'Questions: ' + CONVERT(VARCHAR(400),"
+ " [QUESTION]) AS [TITLE],"
+ " 'KLMS/Question.aspx?id=' + CONVERT(VARCHAR, KMQ.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN KLMS_M_QUESTIONS KMQ"
+ " ON MWL.FK_OBJECT_ID = KMQ.PK_ID INNER JOIN M_USER_DETAILS MUD"
+ " ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = 510 AND MWL.FK_USER_ID = " + userId + " AND"
+ " MWL.IS_ACTIVE = 1 AND KMQ.IS_ACTIVE = 1";
// Query for Test
string selectTest = "SELECT DISTINCT MWL.PK_ID AS PK_ID, 'Tests: ' + KMT.TITLE AS TITLE,"
+ " 'KLMS/Test.aspx?id=' + CONVERT(VARCHAR, KMT.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN KLMS_M_TESTS KMT"
+ " ON MWL.FK_OBJECT_ID = KMT.PK_ID INNER JOIN M_USER_DETAILS MUD"
+ " ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = 515 AND MWL.FK_USER_ID = " + userId + " AND"
+ " MWL.IS_ACTIVE = 1 AND KMT.IS_ACTIVE = 1";
// Query for Course
string selectCourse = "SELECT DISTINCT MWL.PK_ID AS PK_ID, 'Courses: ' + KMC.TITLE AS TITLE,"
+ " 'KLMS/Course.aspx?id=' + CONVERT(VARCHAR, KMC.PK_ID) AS OBJECTURL"
+ " FROM M_WATCHLIST MWL INNER JOIN KLMS_M_COURSES KMC"
+ " ON MWL.FK_OBJECT_ID = KMC.PK_ID INNER JOIN M_USER_DETAILS MUD"
+ " ON MUD.PK_ID = MWL.FK_USER_ID AND MUD.ACTIVE = 1"
+ " WHERE MWL.OBJECT_TYPE = 500 AND MWL.FK_USER_ID = " + userId + " AND"
+ " MWL.IS_ACTIVE = 1 AND KMC.IS_ACTIVE = 1";
//************************************************************************************************
string orderQuery = " ORDER BY " + GridViewSortExpression + " " + GridViewSortDirection;
//For All
if (ddlTypes.SelectedValue == "10")
{
selectStatement = selectArticle + " UNION " + selectTips + " UNION " + selectIdea
+ " UNION " + selectIWantINeed + " UNION " + selectPointCAT + " UNION " + selectSeminar
+ " UNION " + selectCodeCAT + " UNION " + selectNowShowing + " UNION " + selectQA
+ " UNION " + selectMessage + " UNION " + selectDocuments + " UNION " + selectCandidate
+ " UNION " + selectProspect + " UNION " + selectToolCAT;
Can anyone please help me....
Pretty large query. I would add a breakpoint(F9) inside the if and watch the selectStatement; copy the query from there and into my sql editor, and then run/fix it from there.
It seems you are missing some space, or column in the UNION statements.
Related
I have asp.net application to upload database on a remote server using SQLCMD, but the command is not executed. If I execute it in cmd directly it works fine. Here is the code
Dim output
Dim result As String = ""
p.StartInfo.UseShellExecute = False
p.StartInfo.CreateNoWindow = True
p.StartInfo.RedirectStandardInput = True
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.RedirectStandardError = True
p.StartInfo.Verb = "runas"
p.StartInfo.FileName = "cmd.exe"
'p.StartInfo.Arguments = "/c sqlcmd -S " + serverIP + " -U " + sa + " -P " + P#ssw0rd + " -Q" + Chr(34) + " RESTORE DATABASE " + txtDatabaseName.Text + " FROM DISK=" + Chr(39) + dbPath + Chr(39) + " with move " + Chr(39) + oldmdf + Chr(39) + " to 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + mdf + Chr(39) + ", move " + Chr(39) + oldLog + Chr(39) + " to 'C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + txtDatabaseName.Text + "_log.ldf'" + " CREATE Login " + txtDatabaseUser.Text + " WITH PASSWORD = " + Chr(39) + txtDatabasePassword.Text + Chr(39) + ";" + Chr(34)
p.StartInfo.Arguments = "/c sqlcmd -S " + ddlDatabaseServerURL.SelectedValue + " -U " + txtDatabaseServerUsername.Text + " -P " + txtDatabaseServerPassword.Text + " -Q" + Chr(34) + " RESTORE DATABASE " + txtDatabaseName.Text + " FROM DISK=" + Chr(39) + dbPath + Chr(39) + " with move " + Chr(39) + oldmdf + Chr(39) + " to 'F:\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + mdf + Chr(39) + ", move " + Chr(39) + oldLog + Chr(39) + " to 'F:\MSSQL12.MSSQLSERVER\MSSQL\DATA\" + txtDatabaseName.Text + "_log.ldf'" + " CREATE Login " + txtDatabaseUser.Text + " WITH PASSWORD = " + Chr(39) + txtDatabasePassword.Text + Chr(39) + ";" + Chr(34)
Dim strFile As String = "C:\inetpub\vhost\Endpoint_Website\Endpoint_EB\mylog.txt"
Dim fileExists As Boolean = File.Exists(strFile)
Using sw As New StreamWriter(File.Open(strFile, FileMode.OpenOrCreate))
sw.WriteLine(
IIf(fileExists, p.StartInfo.Arguments, Nothing))
End Using
p.Start()
output = p.StandardOutput.ReadToEnd()
Im trying to send json object in Outlook using vba. Here is my code:
Dim Msg As Outlook.MeetingItem
Set Msg = Item
Set recips = Msg.Recipients
Dim regEx As New RegExp
regEx.Pattern = "^\w+\s\w+,\sI351$"
Dim URL As String
URL = "https://webhook.site/55759d1a-7892-4c20-8d15-3b8b7f1bf3b3"
For Each recip In recips
If regEx.Test(recip.AddressEntry) And recip.AddressEntry <> "Application Management Linux1, I351" Then
Dim convertedJson As Object
Set convertedJson = JsonConverter.ParseJson("{""fields"": 123}")
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "POST", URL, False
xhr.setRequestHeader "Content-Type", "application/json"
xhr.Send (convertedJson)
End If
Next
If I send just plane text it works well but i can't send convertedJson. Is it possible to send an object?
UPDATE
I can't even do Debug.Print convertedJson
I was tormented by these libraries in the end I did a very terrible thing
Dim flds, prt, id, smry, descrp, issu, name, lfbrkt, rtbrkt, cma, dbdots, jsTest, issuName As String
flds = "'fields'"
prt = "'project'"
id = "'id'"
smry = "'summary'"
descrp = "'description'"
issu = "'issuetype'"
issuName = "'Improvement'"
name = "'name'"
lfbrkt = "{"
rtbrkt = "}"
cma = ","
dbdots = ":"
jsTest = lfbrkt + flds + dbdots + " " + lfbrkt + vbCrLf + vbTab + prt + dbdots + " " + lfbrkt + vbCrLf + vbTab + vbTab + id + dbdots + " " + "30611" + vbCrLf + vbTab + rtbrkt + cma + vbCrLf + vbTab + smry + dbdots + " " + "'" + CStr(Msg.Subject) + "'" + cma + vbCrLf + vbTab + descrp + dbdots + " " + "'" + CStr(Msg.Body) + "'" + cma + vbCrLf + vbTab + issu + dbdots + " " + lfbrkt + vbCrLf + vbTab + vbTab + name + dbdots + " " + issuName + vbCrLf + vbTab + rtbrkt + vbCrLf + rtbrkt + rtbrkt
And I got this
So I have a query with the following sort order:
String sortOrder = "CASE " + ICCGoal.COLUMNS.category
+ " WHEN '" + GoalCategory.PHYSICAL_ACTIVITY.getEncodedValue() + "' THEN 1"
+ " WHEN '" + GoalCategory.SLEEP.getEncodedValue() + "' THEN 2"
+ " WHEN '" + GoalCategory.SOCIAL.getEncodedValue() + "' THEN 3"
+ " WHEN '" + GoalCategory.MOOD.getEncodedValue() + "' THEN 4"
+ " WHEN '" + GoalCategory.ENERGY.getEncodedValue() + "' THEN 5"
+ " END";
is there anyway to order the sections of the returned values?
Currently, I have all goals of "SLEEP" type returned after the "PHYSICAL_ACTIVITY" and before "SOCIAL" goals, in whatever order they are stored.
Would it be possible to return them ordered by date created? Or just ordered in another way than default?
Just add a secondary sorting criteria:
String sortOrder = "CASE " + ICCGoal.COLUMNS.category
+ " WHEN '" + GoalCategory.PHYSICAL_ACTIVITY.getEncodedValue() + "' THEN 1"
+ " WHEN '" + GoalCategory.SLEEP.getEncodedValue() + "' THEN 2"
+ " WHEN '" + GoalCategory.SOCIAL.getEncodedValue() + "' THEN 3"
+ " WHEN '" + GoalCategory.MOOD.getEncodedValue() + "' THEN 4"
+ " WHEN '" + GoalCategory.ENERGY.getEncodedValue() + "' THEN 5"
+ " END" // Original ordering from the OP
+ ", date_created"; // Secondary term
Trying to get values from my table but having problem with my snytaxes
there is wrong type with "Group By" usage with "AND"
any help will be apriciated
"SELECT " + C_CINSIYET + " FROM " + TABLE_COMPANYS + " WHERE "
+ C_MARKA + " = '" + companyMarka.getComp_marka() + "'"
+ " AND " + C_FIRMA + " = '"
+ companyMarka.getComp_name() + "' GROUP BY "
+ C_CINSIYET + "AND"+C_FIRMA;
code is building the email but it is only displaying one row when there is six. I got it correct on the text file but I need it to do the same in the email message. I think I got the for next statement in the wrong location. Here is the example of the code that I am having problem with. I do not know how to place the for next statement without interrupting the vbLine
For Each p In query
If p.Contract_No IsNot Nothing Then
ContractNo = p.Contract_No
Else
ContractNo = " "
End If
If p.Vendor_Name IsNot Nothing Then
VenderName = p.Vendor_Name
Else
VenderName = " "
End If
If p.Termination_Date IsNot Nothing Then
TerminationDate = p.Termination_Date
' ReportDateStr = ReportDate.ToString
TerminationDateStr = String.Format("{0:MM/dd/yyyy}", TerminationDate)
Else
TerminationDateStr = " "
End If
If p.Dept_Name IsNot Nothing Then
DeptName = p.Dept_Name
Else
DeptName = " "
End If
If p.Renewal_Option_Desc IsNot Nothing Then
RenewalOption = p.Renewal_Option_Desc
Else
RenewalOption = " "
End If
If p.Contract_Desc IsNot Nothing Then
ContractDesc = p.Contract_Desc
Else
ContractDesc = " "
End If
If p.Contact_Email IsNot Nothing Then
ContactEmail = p.Contact_Email
Else
ContactEmail = "** N/A ** "
End If
' sends email with attachment
EmailMsgBody = "-- TOTAL # OF CONTRACTS WITH FAILSAFE DATE ON " + DateStr + " IS: " + icnt.ToString + vbCrLf +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + " *****Contracts**** " +
vbNewLine + " __________________ " +
vbNewLine +
vbNewLine + "Contract#" + " " + "Vender Name" + " " + "Termination Date" + " " + "Dept Name" + " " + "Renewal Option" + " " + "Contract Desc" + " " + "Email Address" +
vbNewLine + "------------" + " " + "-----------------" + " " + "---------------------" + " " + "--------------" + " " + "--------------------" + " " + "-----------------" + " " + "-----------------" +
vbNewLine + ContractNo.PadRight(18) + " " + _
VenderName.PadRight(38) + " " + _
TerminationDateStr.PadRight(26) + " " + _
DeptName.PadRight(27) + " " + _
RenewalOption.PadRight(45) + " " + _
ContractDesc.PadRight(32) + " " + _
ContactEmail.PadRight(11) + " "