列表框未显示SQL表中的所有列

时间:2019-03-05 20:31:08

标签: c# sql

创建一个类以从SQL表[USER]返回列。但是,当数据显示在列表框中时,它仅显示前两列。

返回列的类

Imports System.Linq
Imports System.Collections.Generic
Imports System

Public Class Form1

Private list As New List(Of Integer)()

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    ListBox1.Items.Clear()
    list.Clear()

    list.Add(1)
    list.Add(2)
    list.Add(3)
    list.Add(3)
    list.Add(4)
    list.Add(4)
    list.Add(4)

    For Each value As Integer In list
        ListBox1.Items.Add(value)
    Next
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    ListBox1.Items.Clear()
    Dim distinct As List(Of Integer) = list.Distinct().ToList()

    For Each value As Integer In distinct
        ListBox1.Items.Add(value)
    Next
End Sub
End Class

调用User类并填充列表框

Alias /moodle "C:/wamp64/www/moodle/"

<Directory "C:/wamp64/www/moodle/">
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride all
<ifDefine APACHE24>
    Require all granted
 </ifDefine>
 <ifDefine !APACHE24>
    Order Deny,Allow
 Deny from all
 Allow from localhost ::1 127.0.0.1
 </ifDefine>

  # To import big file you can increase values
  php_admin_value upload_max_filesize 128M
  php_admin_value post_max_size 128M
  php_admin_value max_execution_time 360
  php_admin_value max_input_time 360
  </Directory>

添加断点并进入用户时,可以看到数据正确返回。但是当我查看fullinfo时,我只能看到USER_ID和USERNAME。当我在文本可视化工具中查找fullinfo时,我可以看到所有列均已返回,但它们之间有很大的空格。

3 个答案:

答案 0 :(得分:2)

我数据库的字段中的数据类型为nchar(250)。

我从[USER]表中删除了所有数据,并将字段更新为varchar(250),然后插入了数据。这意味着所有空间都消失了,所有数据都显示了。

答案 1 :(得分:0)

这可能是一个简单的语法错误。我猜它正确读取并显示了USER_ID,因为它是唯一的变量,大括号之间没有空格。然后,它读取下一个变量Username,但是之间有空格,因此可以显示它,但不显示其余的隔开的变量,并且当它在文本可视化器中显示时,它包括您提到的那些空格。我会将您的return语句重新格式化为:

 return $"{USER_ID} {Username} {First_Name} {Surname} {Email}";

希望它能起作用。

答案 2 :(得分:0)

我指的是您的return语句,而不是变量的数据类型/间距。换句话说,您的#include <stdio.h> #define N 6 int main(void) { int num, digits[N], i, invalid, count = 1, sum = 0; TOP: printf("Enter pin code (attempt %d): ", count++); scanf("%d", &num); invalid = num; // stores each digit of the number entered into the the array for (i = 6; i >= 0; i--) { digits[i] = num % 10; num = num / 10; } // if the user enters more than 6 digits than it will give you an error. if (digits[N] > 6) { printf("Code %d is invalid!\n", invalid); goto TOP; } // loops through the array elements and see if each digit is divisble by 2, if not then print an error. for (i = 0; i < 6; i++) { if (digits[i] % 2 != 0) { printf("Code %d is invalid!\n", invalid); goto TOP; } else { printf("Congratulation, code %d is valid!\n", invalid); break; } } return 0; } 语句应该看起来像

return

代替

return $"{USER_ID} {Username} {First_Name} {Surname} {Email}";