Home php c# sql c c++ javascript python java go android git linux asp.net django .net node.js ios xcode cocoa iphone mysql tomcat mongodb bash objective-c scala visual-studio apache elasticsearch jar eclipse jquery ruby-on-rails ruby rubygems android-studio spring lua sqlite emacs ubuntu perl docker swift amazon-web-services svn html ajax xml java-ee maven intellij-idea rvm macos unix css ipad postgresql css3 json windows-server vue.js typescript oracle hibernate internet-explorer github tensorflow laravel symfony redis html5 google-app-engine nginx firefox sqlalchemy lucene erlang flask vim solr webview facebook zend-framework virtualenv nosql ide twitter safari flutter bundle phonegap centos Register | Login | Edit Tags | New Questions | 繁体 | 简体


10 questions online user: 26

0
votes
answers
10 views
+10

VB.net BackGroundWorker在DataGridView中交叉線程

0

我有一個BackGroundWorker,可以在DataGridView中查看mySQL中的數據。在我的DoWork事件VB.net BackGroundWorker在DataGridView中交叉線程

connection() 
    Try 
     conn.Open() 
     Dim query As String 
     query = "SELECT column02 AS 'Company ID', column05 AS Lastname, 
         column06 AS Firstname, column07 AS Middlename, 
         column04 AS 'Contact No.', column13 AS 'Area' 
       FROM table01 
       WHERE column10 = '" & selectedAccount & "' 
       AND column18 = 'Yes'" 
     command = New MySqlCommand(query, conn) 
     dataAdapter.SelectCommand = command 
     dataAdapter.Fill(dataTable) 
     bSource.DataSource = dataTable 
     DataGridView_Accounts.DataSource = bSource 
     For i As Integer = 0 To dataTable.Rows.Count - 1 
      dataTable.Rows(i)("Company ID") = dataTable.Rows(i)("Company ID") 
      dataTable.Rows(i)("Lastname") = dataTable.Rows(i)("Lastname") 
      dataTable.Rows(i)("Firstname") = dataTable.Rows(i)("Firstname") 
      dataTable.Rows(i)("Middlename") = dataTable.Rows(i)("Middlename") 
      dataTable.Rows(i)("Contact No.") = dataTable.Rows(i)("Contact No.") 
      dataTable.Rows(i)("Area") = dataTable.Rows(i)("Area") 
     Next 
     conn.Close() 
    Catch ex As Exception 
     MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) 
    Finally 
     conn.Dispose() 
    End Try 

它是在我的DataGridView中引發錯誤關於跨線程。

我曾嘗試這個移動到RunWorkerCompleted事件

DataGridView_Accounts.DataSource = bSource 
    For i As Integer = 0 To dataTable.Rows.Count - 1 
     dataTable.Rows(i)("Company ID") = dataTable.Rows(i)("Company ID") 
     dataTable.Rows(i)("Lastname") = dataTable.Rows(i)("Lastname") 
     dataTable.Rows(i)("Firstname") = dataTable.Rows(i)("Firstname") 
     dataTable.Rows(i)("Middlename") = dataTable.Rows(i)("Middlename") 
     dataTable.Rows(i)("Contact No.") = dataTable.Rows(i)("Contact No.") 
     dataTable.Rows(i)("Area") = dataTable.Rows(i)("Area") 
    Next 

大約有跨線程沒有更多的錯誤,但是在我的DataGridView我無法查看結果。即使我的數據庫已滿,它也是空的。由於

+0

該循環沒有意義......它所做的只是將行和字段值分配給自己。 – MrGadget

+0

後臺工作正在檢索數據,這是通過調用'Fill'完成的。擺脫那無用的循環。 UI更新是數據綁定,您應該在'RunWorkerCompleted'事件處理程序中執行此操作。 – jmcilhinney

+0

在SQL中有兩個無效的列別名:'column02 AS'公司ID''和'column04 AS'聯繫號'''除非MySql允許它們中有空格。 – MrGadget

沙发
0
1

看看這個讓你更接近的工作...

Imports MySql.Data 

Public Class Form1 

    Private Const ConnectionString As String = "" 

    ' This probably comes from the form but OP did not share that with us. 
    Private selectedAccount As String = "" 

    Private dataTable As New DataTable 

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 
     Task.Run(Sub() DoWork()) 
    End Sub 

    Private Sub DoWork() 
     Dim query As String = "SELECT column02 AS 'CompanyID', column05 AS Lastname, 
           column06 AS Firstname, column07 AS Middlename, 
           column04 AS 'ContactNo', column13 AS 'Area' 
           FROM table01 WHERE column10 = @selectedAccount AND column18 = 'Yes'" 

     Using MySqlConnection As New MySqlClient.MySqlConnection(ConnectionString) 
      Dim MySqlCommand As New MySqlClient.MySqlCommand(query, MySqlConnection) 

      ' Use Parameters to avoid vulnerability to SQL Injection 
      MySqlCommand.Parameters.Add("@selectedAccount", MySqlClient.MySqlDbType.String) 
      MySqlCommand.Parameters("@selectedAccount").Value = selectedAccount 

      Using MySqlDataAdapter As New MySqlClient.MySqlDataAdapter(MySqlCommand) 
       MySqlDataAdapter.Fill(dataTable) 
      End Using 
     End Using 

     RefreshGrid() 
    End Sub 

    Sub RefreshGrid() 
     If Me.InvokeRequired Then 
      ' Shift this call to the UI thread 
      Me.Invoke(Sub() RefreshGrid()) 
     Else 
      bSource.DataSource = dataTable 
      DataGridView_Accounts.DataSource = bSource 
      DataGridView_Accounts.Refresh() 
     End If 
    End Sub 

End Class 

老實說,「漂亮的名字」應在DGV,而不是SQL設置,但那是另一個話題,我沒有追逐這個解決方案。

0
votes
answers
9 views
+10

如何從MySql數據庫中獲取結果並將它們發送回API.ai

0

我需要一些幫助來確定SQL查詢的語法,同時通過連接到Google雲Mysql數據庫的api.ai webhook &使用它們。 雖然查詢工作,在 '請求被超時'如何從MySql數據庫中獲取結果並將它們發送回API.ai

'use strict'; 
const mysql = require('mysql'); 

exports.name = (req, res) => { 

    let action = req.body.result['action']; 

if (action === 'apple') { 


    callDB().then((output) => { 

     res.setHeader('Content-Type', 'application/json'); 
     res.send(JSON.stringify(output)); 
    }).catch((error) => { 

     res.setHeader('Content-Type', 'application/json'); 
     res.send(JSON.stringify(error)); 
    }); 

} 
}; 

function callDB() { 
    return new Promise((resolve, reject) => { 

    try { 

     var connection = mysql.createConnection({ 
      host: "<host>", 
      user: "<user>", 
      password: "<pass>", 
      database: "<DB>" 
     }); 

     connection.query("SELECT description AS solution FROM mtable WHERE title LIKE '%Breakfast%'", function (error, results, fields) { 
      if (!error) { 

       let response = "The result is: " + results[0].solution; 
       response = response.toString(); 
       let output = {'speech': response, 'displayText': response}; 
       console.log(output); 
       resolve(output); 

      } else { 

       let output = {'speech': 'Error. Query Failed.', 'displayText': 'Error. Query Failed4.'}; 
       console.log(output); 
       reject(output); 

      } 
     }); 
     connection.end(); 

    } catch (err) { 
     let output = {'speech': 'try-catch block error', 'displayText': 'try-catch block error3'}; 
     console.log(output); 
     reject(output); 

    } 

} 
); 
} 

如果我取代與此查詢,它的工作原理:

'SELECT描述AS解決方案從mtable WHERE ID LIKE 1001'

ID是列名,只有id`s

標題列名和標題,如早餐包等

這是網絡掛接JSON所示的錯誤的部分:

"metadata": { 
    "intentId": "<id>", 
    "webhookUsed": "true", 
    "webhookForSlotFillingUsed": "false", 
    "webhookResponseTime": 5000, 

"status": { 
"code": 206, 
"errorType": "partial_content", 
"errorDetails": "Webhook call failed. Error: Request timeout.", 
"webhookTimedOut": true 
    }, 

我引用的代碼如下線程, How to get results from MySql DB using node.js MySQL and send them back to API.ai

沙发
0
0

似乎是在您的查詢字符串聲明中的錯別字(接近「%早餐% ''):

connection.query('SELECT description AS solution FROM mtable WHERE title LIKE '%Breakfast%'', function (error, results, fields) { 

在分配您的查詢字符串變量, 'SELECT描述AS解決方案從mtable WHERE標題LIKE '%早餐%'' 被解釋爲一個數字(因爲%運營商)。

以任何方式修復您的單引號是否有幫助?

connection.query("SELECT description AS solution FROM mtable WHERE title LIKE '%Breakfast%'", function (error, results, fields) { 
+0

問候,這確實解決了錯誤,但我仍然沒有從數據庫中獲取任何數據。 json只是說超時。 (API.ai在超時之前僅等待5秒,可能是什麼解決方案?「狀態」:{ 「code」:206, 「errorType」:「partial_content」, 「errorDetails」:「Webhook調用失敗。錯誤:請求超時。「, 」webhookTimedOut「:true – Jarvis

+0

我對API.ai並不熟悉我只在您的JavaScript代碼中發現了一些奇怪的東西 如果它解決了您在問題中提到的第一個問題,您的問題與關於您當前問題(包含錯誤消息)和最重要的信息相關,爲每項涉及的技術(api.ai等)添加標籤。 – RogerC

板凳
0
0

問題必須在您的服務器端與MySQL。我每天都這樣做,並且在5秒鐘內用於查詢的情況下,它可以正常工作。

可能是你的Where子句正在創建全表掃描,因此超時返回Diagflow(> 5秒)或db連接中斷。

您需要在例程和結束週期之前設置定時器,查看您的持續時間。單獨從bash腳本運行查詢並查看需要多長時間。你會發現超時正在發生的地方。在條件兩邊都有搜索參數(%)肯定會比搜索字符串的開始時間(意味着以搜索開始)和%search%(找到包含的任何子字符串)花費更長的時間。

祝你好運。

0
votes
answers
9 views
+10

將數據插入SQL Server表

0

我有這樣的數據將數據插入SQL Server表

MAPPING表1:

ID1 NAME1 
----------- 
001  1 
002  2 

DATA表:

TID_1 TNAME_1 
------------------ 
1  ABCNAME 
2  DEFNAME 

另一個MAPPING表2:

ID2 NAME2 
-------------- 
001 1 
002 2 

DATA表:

TC_ID2 TC_NAME2 
-----------------  
    1  C_NAME 
    2  D_NAME 

這裏映射表中DATABASE2和數據表是databaes1 現在我還有一個dimension_location表中這樣

ID1 NAME1 ID2 NAME2 
------------------------- 

DATABASE2我想插入到這個表像這樣

ID1 NAME1 ID2  NAME2 
-------------------------------- 
001 ABCNAME 001001 C_NAME 
002 DEFNAME 002002 D_NAME 

意味着我想從database1數據表中選擇名稱併爲id我想sel ECT從這裏「ID2」列映射表因爲是ID1和另一個是ID2,所以我結合這些ID並插入ID2專欄中,我該怎麼辦呢?

insert into Dimension_location(ID1,Name1,ID2, Name2) 
select dm.ID1,dv.TNAME_1,dmp.ID2,ds.TC_NAME2from 

ba.dbo.Mappingtable1 dm , 
ba.dbo.Mappingtable2 dmp 

inner join Cen.dbo.datatable1 dv on dm.ID1=dv.TID_1 
inner join Cen.dbo.datatable2 ds on ds.ID2=dmp.TC_ID2 

現在我如何將id1代碼與id2代碼結合?

任何解決方案?

沙发
0
0

您需要使用Fully Qualified Names才能編寫您的查詢。例如:

database_name.schema_name.object_name.column_name

這將是這樣的:

SELECT * 
FROM [database1].[dbo].[MAPPING TABLE] A 
INNER JOIN [database2].[dbo].[DATA TABLE1] B 
    ON A.[] = B.[] 
... 
+0

是我多麼結合ID1與ID2並插入ID2該ID?這是實際問題 –

+0

@這是什麼問題?只需加入相應的表格。 – gotqn

+0

檢查更新查詢 –

0
votes
answers
8 views
+10

運行SSIS包作爲SQL代理作業失敗

1

我創建了SSIS項目,該項目將一些數據導出到Excel。在Visual Studio 2017年它工作正常,但是當我運行它使用SQL Server代理作業(MS SQL服務器2017年),它拋出這個錯誤:運行SSIS包作爲SQL代理作業失敗

"Executed as user: Administrator. Microsoft (R) SQL Server Execute Package 
Utility Version 13.0.1601.5 for 32-bit Copyright (C) 2016 Microsoft. All 
rights reserved. Started: 3:31:46 PM Error: 2017-12-27 15:31:47.10  
Code: 0xC0010018  Source: Package  Description: Error loading value " 
<DTS:ConnectionManagers xmlns:DTS="www.microsoft.com/SqlServer/Dts"> 
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[Excel]" 
DTS:CreationName="EXCEL" DTS:DTSID="{0E7AADD0-AA79-4C99-8FFC-92E1CB5A871A}" 
DTS:ObjectName="Excel"><DTS:ObjectData><DTS" from node 
"DTS:ConnectionManagers". End Error Could not load package "\phantsmgmtc$SDATAITDokumentaceSQL_DT_projectsExport_ser_zak_CEBIAExport_ser_zak_CEBIAExport_ser_zak_CEBIAPackage.dtsx" 
because of error 0xC0010014. Description: The package failed to load due to 
error 0xC0010014 "One or more error occurred. There should be more specific 
errors preceding this one that explains the details of the errors. This 
message is used as a return value from functions that encounter errors.". 
This occurs when CPackage::LoadFromXML fails. Source: Package Started: 
3:31:46 PM Finished: 3:31:47 PM Elapsed: 0.422 seconds. The package 
could not be loaded. The step failed." 

也就是說STANGE,因爲我有另外一個SSIS項目,也在使用Excel連接管理器,並且它使用預定的SQL Server代理作業正常工作。

我試着打開和關閉32位模式,但沒有任何幫助。

+1

你是否安裝了軟件包到文件系統或數據庫?該包是否確實位於\ phantsmgmt c $ SDATA ITDokumentace SQL_DT_projects Export_ser_zak_CEBIA Export_ser_zak_CEBIA Export_ser_zak_CEBIA Package.dtsx中? – HardCode

+0

是的,文件系統,它真的存在於那個位置。問題出在VS中配置的目標服務器版本中。見下文 – WhiteB1

沙发
0
0

他們主要錯誤是:

Error loading value " 
<DTS:ConnectionManagers xmlns:DTS="www.microsoft.com/SqlServer/Dts"> 
<DTS:ConnectionManager DTS:refId="Package.ConnectionManagers[Excel]" 
DTS:CreationName="EXCEL" DTS:DTSID="{0E7AADD0-AA79-4C99-8FFC-92E1CB5A871A}" 
DTS:ObjectName="Excel"><DTS:ObjectData><DTS" from node 
"DTS:ConnectionManagers". End Error 

它看起來像錯誤是從Excel的連接管理器,也就是不能被加載的值。首先你必須檢查是否存在excel文件路徑。如果文件是在包執行後創建的,則必須爲使用此連接的每個組件設置DelayValidation屬性爲True

板凳
0
0
0
votes
answers
8 views
+10

來自一列的組夥伴

0

我在名爲claim.files的一個表中有兩列,第一列被命名爲'claim'並且包含聲明文件編號ex。 4355,6444,7674等,第二個被命名爲「合作伙伴」,幷包含ex的合作伙伴代碼。 8393,4783,38283. 索賠文件號碼是唯一的,但每個索賠文件可以有更多的合作伙伴,所以我想要運行一個可以將每個索賠文件的所有合作伙伴分組的選擇。如果我運行這個「選擇聲明,聲稱來自claim.files的合作伙伴(4355,6444,7674)聲明中的聲明,合作伙伴」,如果它擁有更多合作伙伴,它將複製聲明。來自一列的組夥伴

我想要的結果是象下面這樣:

claim partners 
4355 57878, 45874, 58977 

如果我運行下面的代碼會重複索賠數

select claim, partner from claim.files where claim in (4355, 6444, 7674) group by claim, partner 

這樣做的結果會如何,如果我運行上面的選擇

claim partners 
    4355 57878 
    4355 45874 
    4355 58977 
+0

請參閱https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very- simple-sql-query – Strawberry

+0

請發佈正確的sql語句。這個snr是什麼?通過僅與像sum()或average() – mbieren

+1

等函數一起工作的羣組,請解釋如何索賠可以有更多的合作伙伴,如果它們是獨特的,並且snr在圖片中的位置。 – isaace

沙发
0
1

如果要選擇爲每個claim分隔的夥伴逗號,y您可以同時使用group_concat

select claim, group_concat(partner separator ',') as partners 
from files 
where snr in (4355, 6444, 7674) 
group by claim; 

Demo

| claim |   partners | 
|-------|-------------------| 
| 4355 | 57878,45874,58977 | 

更新時間:如果您使用的是SQL服務器,你可以這樣做,而不是:

SELECT 
    f1.claim, 
    STUFF((
      SELECT ',' + CAST(f2.partner AS NVARCHAR(50)) 
      FROM files as f2 
      where snr in (4355, 6444, 7674) 
      and f1.claim = f2.claim 
      FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') AS partners 
FROM files as f1 
where snr in (4355, 6444, 7674) 
group by f1.claim; 

- SQL Server demo

| claim |   partners | 
|-------|-------------------| 
| 4355 | 57878,45874,58977 | 
+0

它不工作,我有一個SQL客戶端 – haxx

+1

@haxx你是什麼意思的SQL客戶端?它如何不起作用?沒有提供預期的結果?或者你有錯誤? – 2017-12-27 14:51:26

+0

我得到的錯誤:錯誤:[SQL0204]找不到* LIBL類型* N中的GROUP_CONCAT。 SQLState:42704 ErrorCode:-204 – haxx

0
votes
answers
8 views
+10

錯誤53:文件未找到,而是所有的DLL都存在於路徑中

0

我創建了一個DLL(使用C++),它依賴於sqlite3.dll(用於數據庫訪問& sqlcipher),我試圖使用VBA來訪問它。在VBA我使用以下聲明:錯誤53:文件未找到,而是所有的DLL都存在於路徑中

Declare Function GetData_VBA Lib "xyz.dll" (ByVal path As String, ByVal id As String, ByRef inputArr() As String, ByRef output() As String) As Boolean 

早些時候當DLL是不依賴於sqlite3.dll它工作正常,但是當我介紹sqlite3.dll它開始嘔吐錯誤

錯誤53:xyz.dll沒有找到

我試圖改變聲明

Declare Function GetData_VBA Lib "C:documentsuser...projectsxyz.dll" (ByVal path As String, ByVal id As String, ByRef inputArr() As String, ByRef output() As String) As Boolean 

但仍顯示相同的事情。我用dependency walker來檢查對xyz.dll的所有依賴。我嘗試將所有xyz.dll & sqlite3.dll放在同一位置,但仍然是相同的錯誤。

+0

你的dll是否在C++環境中測試過? –

+0

sqlite3.dll在您的PATH環境變量中的位置,如果不是,則考慮添加它。或者,如果您正在控制其安裝位置,則可以使用特定位置的LoadLibrary手動加載它。 –

+0

您確定您的* .dll *和* sqlite3.dll *之間沒有架構不匹配(32/64位)嗎? – CristiFati

沙发
0
0

cryptlib.lib缺少sqlite3.dll從屬關係。我已經提供了.lib文件,它工作。

0
votes
answers
8 views
+10

在C#中創建的表達式樹使用LINQ.Expressions

0

對於下面的示例學生名單我想選擇使用表達式樹列表中多條記錄,選擇多個記錄(生成動態LINQ查詢)在C#中創建的表達式樹使用LINQ.Expressions

- 1 | John | 13 
- 2 | Steve | 15 
- 3 | Bill | 18 
- 4 | Ram | 12 
- 5 | Ron | 21 

對於選擇單條記錄

SQL Query: 
select * from studentList where StudentID = 2 

LINQ:

var studentsData = studentList.Where(s=>s.StudentID == 2).AsQueryable(); 

我同樣需要創建的表達式樹從值

例如SQL查詢的列表中選擇多個記錄:

From the list of IDs I need create expression for selecting records  
select * from studentList where StudentID in (2,4,3) 

輸出樣本:

- 2 | Steve 
- 4 | Ram 
- 3 | Bill 

樣品表達樹代碼:

using System; 
using System.Linq; 
using System.Linq.Expressions; 
using System.Collections.Generic; 

public class Program 
{ 
public static void Main() 
{ 
    IList<Student> studentList = new List<Student>() { 
     new Student() { StudentID = 1, StudentName = "John", Age = 13 } , 
     new Student() { StudentID = 2, StudentName = "Steve", Age = 15 } , 
     new Student() { StudentID = 3, StudentName = "Bill", Age = 18 } , 
     new Student() { StudentID = 4, StudentName = "Ram" , Age = 12 } , 
     new Student() { StudentID = 5, StudentName = "Ron" , Age = 21 } 
    }; 
    var studentwithLinQ = studentList.Where(s=>s.StudentID == 2); 
    foreach(var stu in studentwithLinQ) 
    Console.WriteLine("{0} | {1}",stu.StudentID, stu.StudentName); 
    ParameterExpression pe = Expression.Parameter(typeof(Student), "s"); 
    MemberExpression me = Expression.Property(pe, "StudentID"); 
    int id = 2; 
    ConstantExpression constant = Expression.Constant(id, typeof(int)); 
    BinaryExpression body = Expression.Equal(me, constant); 
    Expression predicateExpression = Expression.Lambda(body, pe); 
    var sourcequery = studentList.AsQueryable(); 
    Expression sourceExpression = Expression.Convert(Expression.Constant(sourcequery), typeof(IQueryable<Student>)); 
    Expression filterExpressionExpression = Expression.Constant(predicateExpression); 
    var queryExpression = Expression.Call(typeof(Queryable), "Where", new Type[] { typeof(Student)}, sourceExpression,filterExpressionExpression); 
    sourcequery = Expression.Lambda(queryExpression).Compile().DynamicInvoke() as IQueryable<Student>; 
    Console.WriteLine("sourceExpression: {0}", sourcequery); 
    var studentWithExpression = sourcequery; 
    foreach(var stu in studentWithExpression) 
    Console.WriteLine("{0} | {1}",stu.StudentID, stu.StudentName); 
    } 
} 

public class Student{ 
    public int StudentID { get; set; } 
    public string StudentName { get; set; } 
    public int Age { get; set; } 
} 

我可以創建一個用於選擇單個記錄的表達式代碼。但是我無法使用datalist中的多條記錄選擇值。請幫助我使用表達式條件選擇多個值。

沙发
0
2

我認爲試圖用表達式來修復它是一個地獄般的工作。這些功能已經可以通過現有的方法實現。 (這使您的解決方案更簡單) ;-)

你可以試試這個:

// your original set 
IList<Student> studentList = new List<Student>() { 
    new Student() { StudentID = 1, StudentName = "John", Age = 13 } , 
    new Student() { StudentID = 2, StudentName = "Steve", Age = 15 } , 
    new Student() { StudentID = 3, StudentName = "Bill", Age = 18 } , 
    new Student() { StudentID = 4, StudentName = "Ram" , Age = 12 } , 
    new Student() { StudentID = 5, StudentName = "Ron" , Age = 21 } 
}; 

// create a subselection of ids only into an array(or list) of the id's only. 
// results in `int[] { 1, 2, 3, 4, 5 };` 
var ids = studentList.Select(student => student.StudentID).ToArray(); 

// use it on the studentList. 
var studentwithLinQ = studentList.Where(s => ids.Contains(s.StudentID)); 

的ID陣列將被轉換爲IN (..)聲明。

板凳
0
1

可以爲此創建一個表達式樹,但這是做事困難的方式。更簡單的是剛剛創建的ID列表:

var ids = new List<int> { 2, 3, 4 }; 

,只是使用:

var filtered = studentList.Where(x => ids.Contains(x.StudentID)); 
0
votes
answers
8 views
+10

字符串轉換爲日期SQLite和與當前日期比較

-1
CREATE TABLE `FormMapping` (
    `PatNum` TEXT, 
    `FormName` TEXT, 
    `SheetNum` TEXT, 
    `IsCompleted` TEXT, 
    `RecordDate` TEXT, 
    `FormOrder` TEXT, 
    PRIMARY KEY(`PatNum`,`SheetNum`) 
); 

以上是我的表結構字符串轉換爲日期SQLite和與當前日期比較

RecordDate甲是「MM/DD/YYYY」

如何轉換「RecordDate」日期和比較在SQLite當前日期?

在此先感謝

+1

這與iOS和Android有什麼關係? – the4kman

+0

不是有效的問題 – HassanUsman

+1

SQLite沒有「日期對象」 – Selvin

沙发
0
1

它與值進行比較後,做了太多的努力我解決了問題,並查詢如下,

DELETE FROM FormMapping WHERE strftime(substr(RecordDate, 7, 4) ||'-'||substr(RecordDate, 1, 2) ||'-'|| substr(RecordDate, 4, 2)) < DATE('now','-7 day') 

謝謝大家的支持。

板凳
0
-1

你可以嘗試將當前的日期,而不是再以dB

public static String simplerDate() { 

     try { 
      Date currentTime = Calendar.getInstance().getTime(); 
      return new SimpleDateFormat("MMM dd ''yy, HH:mm", Locale.ENGLISH).format(date); 
     } catch (ParseException pe) { 
      //Log.i(Utils.class.getSimpleName(), "simplerDate: " + pe); 
      return "N/A"; 
     } 
    } 
+0

爲什麼downvote? – Bmbariah

0
votes
answers
8 views
+10

Oracle Apex創建存儲過程

0

我對apex和存儲過程非常陌生。這只是我創建的一個簡單示例過程。但它保持輸出「編譯錯誤成功」。希望有人能幫忙,提前感謝。Oracle Apex創建存儲過程

CREATE OR REPLACE PROCEDURE get_client_info AS 
BEGIN 
    select CLIENTID from client 
END get_client_info 
+0

如果您使用APEX的SQL命令窗口創建此,以供將來參考,你可以看到在對象錯誤對象瀏覽器(找到你的程序並點擊「錯誤」標籤)。 –

沙发
0
0

分號;,變量聲明和返回由into條款缺失。外

SQL>set serveroutput on; 
SQL>CREATE OR REPLACE PROCEDURE get_client_info AS 
    v_CLIENTID client.CLIENTID%type; 
BEGIN 
    select CLIENTID into v_CLIENTID from client; 
    dbms_output.put_line(v_CLIENTID); 
END get_client_info; -- no need to use "get_client_info" part here, i mean using "END;" is enough, if you'd like. 
/
SQL>exec get_client_info; 

或返回結果值:請嘗試以下一個

SQL>CREATE OR REPLACE PROCEDURE get_client_info(o_CLIENTID out client.CLIENTID%type) AS 
    BEGIN 
     select CLIENTID into o_CLIENTID from client; 
    END; 
    /
    SQL>var clinfo varchar2; 
    SQL>exec get_client_info(:clinfo); 
    SQL>print clinfo; 
0
votes
answers
8 views
+10

如何將我的統一項目連接到EC2實例上的mysql服務器

1

我想從我的MySQL服務器獲取數據到我的Unity項目。我試圖讓像這樣的數據:如何將我的統一項目連接到EC2實例上的mysql服務器

public string awsurl = "ec2-174-129-82-141.compute-1.amazonaws.com/connect_to_server.php"; 
IEnumerator GetScores() 
{ 
     print("get scores start"); 
     WWW aws_get = new WWW(awsurl); 
     yield return aws_get; 
     print("getscore here"); 
     if (aws_get.error != null) 
     { 
      print("There was an error getting aws: " + aws_get.error); 
     } 
     else 
     { 
      print(aws_get.text); // this is a GUIText that will display the scores in game. 
     } 
} 

我有一個PHP腳本我的服務器來處理,因爲我使用的的MySqlConnection庫我合一項目有麻煩的互動上。 這裏是我的PHP腳本:

$address = "localhost" 
$dbusername = "root"; 
$dbpassword = "root"; 
$db_name = "watshoes"; 
$db_conn = new mysqli($address, $dbusername, $dbpassword, $db_name); 
    if(isset($_POST['username'])) $username = $_POST['username']; 
    if(isset($_POST['user_id'])) $user_id = $_POST['user_id']; 
    if(isset($password)) $password =$_POST['password']; 

    $stmt = $db_conn->prepare("SELECT image FROM ImageText"); 
    // "s" means the database expects a string 
    $stmt->bind_param("s", $user_id); 
    if($stmt->execute()) 
    { 
     /* bind result variables */ 
     $stmt->bind_result($image); 
     /* fetch value */ 
     $stmt->fetch(); 
     echo $image; 
    } 
    else 
    { 
     echo "query failed"; 
    } 
    $stmt->close(); 
    $db_conn->close(); 

但每次我運行代碼時我得到這個錯誤:There was an error getting aws: Failed to connect to ec2-174-129-82-141.compute-1.amazonaws.com port 80: Timed out

感謝您看代碼,並請讓我知道如果有什麼我可以做幫助。