有10行primary_student_table.
当我执行以下代码时,结果为-1.
Dim count As Int16
con.Open()
query = "SELECT COUNT(roll) AS rollcount FROM primary_student_table WHERE admityear = 2011 AND batch = 1 "
cmd = New SqlCommand(query, con)
count = cmd.ExecuteNonQuery
MsgBox(count)
con.Close()
Run Code Online (Sandbox Code Playgroud)
上面的代码有什么问题?
我使用以下代码来清除
txtint1.Clear()
txtext1.Clear()
txttot1.Clear()
txtint2.Clear()
txtext2.Clear()
txttot2.Clear()
txtint3.Clear()
txtext3.Clear()
txttot3.Clear()
txtint4.Clear()
txtext4.Clear()
txttot4.Clear()
txtint5.Clear()
txtext5.Clear()
txttot5.Clear()
txtint6.Clear()
txtext6.Clear()
txttot7.Clear()
txtint8.Clear()
txtext8.Clear()
txttot8.Clear()
Run Code Online (Sandbox Code Playgroud)
有没有可能一次清除所有文本框控件或用几行代码清除?
我需要根据用户的输入将文本MALE或FEMALE插入表格中.
我曾经按照以下代码插入,但如果没有(男/女)选择,代码会插入值1.
query = "INSERT INTO student_profile_table(gender) VALUES(@gender)"
cmd = New SqlCommand(query, con)
If rbtmale.Checked = True Then
cmd.Parameters.AddWithValue("@gender", "Male")
ElseIf rbtfemale.Checked = True Then
cmd.Parameters.AddWithValue("@gender", "Female")
Else
cmd.Parameters.AddWithValue("@gender", vbNull)
End If
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Run Code Online (Sandbox Code Playgroud)
需要一些建议/更正
我尝试了以下代码,但列仍然继承了表的字段名称
DataGridView1.DataSource = ds.Tables("student_attendance_table")
With DataGridView1
.RowHeadersVisible = False
.Columns(0).Name = "Register No."
.Columns(1).Name = "Date"
.Columns(2).Name = "Year"
.Columns(3).Name = "Batch"
.Columns(4).Name = "Hour 1"
.Columns(5).Name = "Hour 2"
.Columns(6).Name = "Hour 3"
.Columns(7).Name = "Hour 4"
.Columns(8).Name = "Hour 2"
.Columns(9).Name = "Attendance"
End With
Run Code Online (Sandbox Code Playgroud)
内容如下:
1138M0345 27-07-2013 3 1 P P P P P P
1138M0346 27-07-2013 3 1 P P P P P P
1138M0347 27-07-2013 3 1 P P P P P P
1138M0348 27-07-2013 …Run Code Online (Sandbox Code Playgroud) 我需要使用两个数组进行Reverse Intersection操作,并将结果保存在不同的数组中
例如:数组A {1,2,3}; 数组B {1,2,3,4,5,6}结果数组应为{4,5,6}
我试过以下逻辑,但没有奏效
int k = 0;
int a[2] = {1,10};
int p[10];
int roll[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for (int i = 0; i < 2; i++)
{
for (int j = 1; j <= 10; j++)
{
if (a[i] == roll[j])
{
break;
}
else
{
p[k] = 0;
p[k] = roll[j];
k++;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的vb.net项目需要它