Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vb.net如何显示postgresql中的选定数据?_Vb.net_Postgresql - Fatal编程技术网

vb.net如何显示postgresql中的选定数据?

vb.net如何显示postgresql中的选定数据?,vb.net,postgresql,Vb.net,Postgresql,为什么即使我正确声明了数据库名称及其表,但始终说“TracingApp_fmemployeesuppliersfeedbackquestions”的错误不存在,我只想知道,如果数据库中存在firstname和lastname,我搜索的记录将显示在DataGridView1中 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim dt As New DataTab

为什么即使我正确声明了数据库名称及其表,但始终说“TracingApp_fmemployeesuppliersfeedbackquestions”的错误不存在,我只想知道,如果数据库中存在firstname和lastname,我搜索的记录将显示在DataGridView1中

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim dt As New DataTable
        Dim firstname = firstnametextbox.Text.Trim()
        Dim lastname = lastnametextbox.Text.Trim()
        Try
            Using MyCon As New Odbc.OdbcConnection("Driver={PostgreSQL ANSI};database=contacttracing;server=localhost;port=5432;uid=*****;sslmode=disable;readonly=0;protocol=7.4;User ID=*****;password=*****;"),
                    cmd As New Odbc.OdbcCommand("SELECT firstname= '" & firstname & "', lastname= '" & lastname & "' FROM TracingApp_fmemployeesuppliersfeedbackquestions ", MyCon)
                MyCon.Open()
                dt.Load(cmd.ExecuteReader)
            End Using
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        DataGridView1.DataSource = dt
    End Sub
这是我的postgresql树

这就是我得到的错误

更新

我也试过这个

Odbc.OdbcCommand("SELECT firstname= '" & firstname & "', lastname= '" & lastname & "' FROM public.TracingApp_fmemployeesuppliersfeedbackquestions ", MyCon)

它也不起作用…

我建议将表名用引号括起来:

"SELECT * FROM ""TracingApp_fmemployeesuppliersfeedbackquestions"" " 
用于将单个
转换为VB字符串

我建议这样做是因为我知道PG会将所有不带引号的表名转换为小写(从“关系不存在”错误消息中可以看出)但是查询工具树显示表名中的一些字母是大写的,因此我怀疑表名是根据大小写创建的,
TracingApp\u fmemployeesuppliersfeedbackquestions
不同于
TracingApp\u fmemployeesuppliersfeedbackquestions


如果没有其他应用程序在使用数据库,那么更改表名可能不会那么麻烦,这样您就不必在VB字符串中填入大量的

我建议用引号括住表名:

"SELECT * FROM ""TracingApp_fmemployeesuppliersfeedbackquestions"" " 
用于将单个
转换为VB字符串

我之所以建议这样做,是因为我知道PG会将所有不带引号的表名转换为小写(从“关系不存在”错误消息中可以看出),但查询工具树显示表名中的某些字母是大写的,因此我怀疑表名是按大小写区分的,而
TracingApp\u fmemployeesuppliersfeedbackquestions
TracingApp\u fmployeesuppliersfeedbackquestions


如果没有其他应用程序在使用数据库,那么更改表名对您来说可能不那么麻烦,这样您就不必在VB字符串中填充大量的

完全限定表名会有什么不同吗
FROM public.TracingApp_fmemployeesuppliers反馈问题
Odbc.OdbcCommand(“SELECT firstname=”、&firstname&“、lastname=”、&lastname&“FROM public.TracingApp_fmemployeesuppliers反馈问题”,MyCon),相同错误,它不起作用@NateBarbettini先生我以前从未见过有人通过允许变量列别名来安排SQL注入..从公共中选择*。“TracingApp_TremployeeSupplierShousembersSubmittedRecords”按id排序ASC@CaiusJard这是结果注:使用参数,当前的方式是SQL注入。完全限定表名是否有区别
FROM public.TracingApp_fmemployeesuppliers反馈问题
Odbc.OdbcCommand(“SELECT firstname=”、&firstname&“、lastname=”、&lastname&“FROM public.TracingApp_fmemployeesuppliers反馈问题”,MyCon),相同错误,它不起作用@NateBarbettini先生我以前从未见过有人通过允许变量列别名来安排SQL注入..从公共中选择*。“TracingApp_tremployeesuppliershousembersSubmittedRecords”按id排序ASC@CaiusJard这是结果注:使用参数,当前的方式是SQL注入的基础。