16,722
社区成员




Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim id, name, age, grade As String
Dim count As Integer
id = Trim(TextBox1.Text)
name = Trim(TextBox2.Text)
grade = Trim(TextBox3.Text)
age = Trim(TextBox4.Text)
If id = "" Then
MessageBox.Show("学号不能为空")
Return
End If
Dim com As OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader ' cmd.CommandText = _
' "SELECT * FROM Titles JOIN Publishers " _
' & "ON Publishers.PubId = Titles.PubID " _
' & "WHERE Publishers.State = 'CA'"
com = New OleDb.OleDbCommand
Dim conn As New OleDb.OleDbConnection
com.CommandText = _
("select count * from student where student.id='" & id &"'") 错误提示:应为")"
>注意传参数的引号,字符串用'
com.Connection = Conn
Conn.open()
dr = com.ExecuteReader
dr.Read()
count = dr.GetValue(0)
dr.Close()
If count <> 0 Then
MessageBox.Show("学号重复!请确认")
Else
com=new OleDb.OleDbCommand ("insert into student(id,name,age,grade)values("'" & id & "','" & name & "','" & age & "','" & grade & "'"),conn) 错误提示:应为逗号、“)”或有效的表达式继续符
>注意传参数的引号,字符串用'
End If
com.Dispose()
conn.close()
End Sub
End Class
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand("select course from course order by c_id",conn)
Dim dr As OleDb.OleDbDataReader 错误提示:"conn"不是"string"的成员
>是, 不是.
Dim course As String
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyValue = 13 Then
Dim id As String
Dim count As Integer
id = Trim(TextBox1.Text)
Dim com As New OleDb.OleDbCommand
dim com as New OleDb.OleDbCommand("select count(*)from student where id='" & id & "'",conn)
Dim dr As OleDb.OleDbDataReader 错误提示:应为逗号、“)”或有效的表达式继续符
>字符串连接时要用空格表示
End If
End Sub
Private Sub OleDbConnection1_InfoMessage(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbInfoMessageEventArgs) Handles OleDbConnection1.InfoMessage
End Sub
End Class
Public Class Form5
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim id, course As String
id = Trim(TextBox1.Text)
course = Trim(ComboBox1.SelectedItem)
If id = "" Then
MessageBox.Show("请输入学号!")
Return
End If
If course = "" Then
MessageBox.Show("请选择课程!")
Return
End If
Dim com As New OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader
Dim conn As New OleDb.OleDbConnection
com.Connection = conn
com.CommandText = _
"select mark from stumark,student where stumark.id=student.id and student.id='" _
id"'and stumark.c_id=(select c_id from course where course='"&course&") _
错误提示:应为语句结束
>"select stumark.mark from stumark inner join student on stumark.id=student.id and student.id='" & _
id "' inner join course on student.id=course.c_id where student.id='" & id & "' and course.c_id='" & course & "'")
conn.open()
dr = com.ExecuteReader
dr.Read()
TextBox4.Text = Trim(dr.GetString(0))
dr.Close()
com.Dispose()
conn.close()
Button1.Enabled = True
End Sub
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim id, name, age, grade As String
Dim count As Integer
id = Trim(TextBox1.Text)
name = Trim(TextBox2.Text)
grade = Trim(TextBox3.Text)
age = Trim(TextBox4.Text)
If id = "" Then
MessageBox.Show("学号不能为空")
Return
End If
Dim com As OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader ' cmd.CommandText = _
' "SELECT * FROM Titles JOIN Publishers " _
' & "ON Publishers.PubId = Titles.PubID " _
' & "WHERE Publishers.State = 'CA'"
com = New OleDb.OleDbCommand
Dim conn As New OleDb.OleDbConnection
com.CommandText = _
("select count * from student where student.id='" & id &"'") 错误提示:应为")"
>注意传参数的引号,字符串用'
com.Connection = Conn
Conn.open()
dr = com.ExecuteReader
dr.Read()
count = dr.GetValue(0)
dr.Close()
If count <> 0 Then
MessageBox.Show("学号重复!请确认")
Else
com=new OleDb.OleDbCommand ("insert into student(id,name,age,grade)values("'" & id & "','" & name & "','" & age & "','" & grade & "'"),conn) 错误提示:应为逗号、“)”或有效的表达式继续符
>注意传参数的引号,字符串用'
End If
com.Dispose()
conn.close()
End Sub
End Class
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand("select course from course order by c_id",conn)
Dim dr As OleDb.OleDbDataReader 错误提示:"conn"不是"string"的成员
>是, 不是.
Dim course As String
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyValue = 13 Then
Dim id As String
Dim count As Integer
id = Trim(TextBox1.Text)
Dim com As New OleDb.OleDbCommand
dim com as New OleDb.OleDbCommand("select count(*)from student where id='" & id & "'",conn)
Dim dr As OleDb.OleDbDataReader 错误提示:应为逗号、“)”或有效的表达式继续符
>字符串连接时要用空格表示
End If
End Sub
Private Sub OleDbConnection1_InfoMessage(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbInfoMessageEventArgs) Handles OleDbConnection1.InfoMessage
End Sub
End Class
Public Class Form5
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim id, course As String
id = Trim(TextBox1.Text)
course = Trim(ComboBox1.SelectedItem)
If id = "" Then
MessageBox.Show("请输入学号!")
Return
End If
If course = "" Then
MessageBox.Show("请选择课程!")
Return
End If
Dim com As New OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader
Dim conn As New OleDb.OleDbConnection
com.Connection = conn
com.CommandText = _
"select mark from stumark,student where stumark.id=student.id and student.id='" _
id"'and stumark.c_id=(select c_id from course where course='"&course&") _
错误提示:应为语句结束
>"select stumark.mark from stumark inner join student on stumark.id=student.id and student.id='" & _
id "' inner join course on student.id=course.c_id where student.id='" & id & "' and course.c_id='" & course & "'")
conn.open()
dr = com.ExecuteReader
dr.Read()
TextBox4.Text = Trim(dr.GetString(0))
dr.Close()
com.Dispose()
conn.close()
Button1.Enabled = True
End Sub
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim id, name, age, grade As String
Dim count As Integer
id = Trim(TextBox1.Text)
name = Trim(TextBox2.Text)
grade = Trim(TextBox3.Text)
age = Trim(TextBox4.Text)
If id = "" Then
MessageBox.Show("学号不能为空")
Return
End If
Dim com As OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader ' cmd.CommandText = _
' "SELECT * FROM Titles JOIN Publishers " _
' & "ON Publishers.PubId = Titles.PubID " _
' & "WHERE Publishers.State = 'CA'"
com = New OleDb.OleDbCommand
Dim conn As New OleDb.OleDbConnection
com.CommandText = _
("select count * from student " _
& "where student.id="&id&"") '错误提示:应为")"
com.Connection = Conn
Conn.open()
dr = com.ExecuteReader
dr.Read()
count = dr.GetValue(0)
dr.Close()
If count <> 0 Then
MessageBox.Show("学号重复!请确认")
Else
com=new OleDb.OleDbCommand ("insert into student(id,name,age,grade)values("&id&",'"&name&"','"&age&"','"&grade&"')"),conn) '错误提示:应为逗号、“)”或有效的表达式继续符
End If
com.Dispose()
conn.close()
End Sub
End Class
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim conn As New OleDb.OleDbConnection
Dim com As New OleDb.OleDbCommand("select course from course order by c_id",conn)
Dim dr As OleDb.OleDbDataReader '错误提示:"conn"不是"string"的成员
Dim course As String
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyValue = 13 Then
Dim id As String
Dim count As Integer
id = Trim(TextBox1.Text)
Dim com As New OleDb.OleDbCommand
dim com as New OleDb.OleDbCommand("select count(id)from student where id='"&id&"'",conn)
Dim dr As OleDb.OleDbDataReader '错误提示:应为逗号、“)”或有效的表达式继续符
End If
End Sub
Private Sub OleDbConnection1_InfoMessage(ByVal sender As System.Object, ByVal e As System.Data.OleDb.OleDbInfoMessageEventArgs) Handles OleDbConnection1.InfoMessage
End Sub
End Class
Public Class Form5
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim id, course As String
id = Trim(TextBox1.Text)
course = Trim(ComboBox1.SelectedItem)
If id = "" Then
MessageBox.Show("请输入学号!")
Return
End If
If course = "" Then
MessageBox.Show("请选择课程!")
Return
End If
Dim com As New OleDb.OleDbCommand
Dim dr As OleDb.OleDbDataReader
Dim conn As New OleDb.OleDbConnection
com.Connection = conn
com.CommandText = _
"select mark from stumark,student where stumark.id=student.id and student.id='"&id&"'and stumark.c_id=(select c_id from course where course='"&course&"') '错误提示:应为语句结束
conn.open()
dr = com.ExecuteReader
dr.Read()
TextBox4.Text = Trim(dr.GetString(0))
dr.Close()
com.Dispose()
conn.close()
Button1.Enabled = True
End Sub