0
我想執行我的postgres函數在VBNet中有日期作爲參數,並在datagridview.Below中顯示結果我的代碼請告訴我我錯在哪裏。我想我寫錯誤的命令來執行function.I知道這可能是錯誤的方式,但我第一次使用Postgres的功能VBNet在VBNet中執行Postgres函數
Imports Npgsql
Public Class Form1
Dim connstring As String = String.Format("Server=127.0.0.1;Port=5432;" +
"Username=xxxx;Password=xxxx;Database=EMS_Demo_db;")
Dim conn As NpgsqlConnection = New NpgsqlConnection(connstring)
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
conn.Open()
Dim Command As NpgsqlCommand = New NpgsqlCommand("SELECT * FROM lastsevendays_sp ' + DateTimePicker1.Value + '", conn)
Dim reader As NpgsqlDataReader = Command.ExecuteReader()
Dim data_Table1 As New DataTable
data_Table1.Load(reader)
DataGridView1.DataSource = data_Table1
reader.Close()
conn.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
'lastsevendays_sp'是存儲過程正確? –
是的這是一個存儲過程 – Parth
什麼是日期參數的名稱? –