'Execute Postgres Function in VBNet
I want to execute my postgres function having date as parameeter in VBNet and show the result in datagridview.Below is my code Please tell me where i am getting wrong.I think i am writing wrong command to execute function.I know this might be wrong way but i am using first time postgres function in VBNet
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
