我在VB2005 里做一个注册功能的页面,连接ACCESS数据库,运行到下面的代码,也不提示错误,只是运行崩溃,是啥原因?
Dim objolecon As OleDbConnection
Dim objcmd As OleDbCommand
Dim strsql, strcon As String
Dim count As Integer strcon = "Provider = Microsoft.Jet.OLEDB.4.0;" & "data source =../../welding.mdb"
'If userNameBoolean = True And passwordBoolean = True Then
If Tablename = "teacher" Then
strsql = "insert into [Teacher](TeacherName,TeacherCode)values('" & userName & "','" & Password & "')" '加入教师姓名、密码
Else
strsql = "insert into [Student](StudentName,StudentCode)values('" & userName & "','" & Password & "')" '加入学生姓名、密码 End If
'End If
objolecon = New OleDbConnection(strcon)
objolecon.Open()
objcmd = New OleDbCommand(strsql, objolecon) count = objcmd.ExecuteNonQuery()
If count = 1 Then
MessageBox.Show("添加记录成功,请联系管理员对数据进行完善!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("添加记录失败,请重新注册!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning) End If
Dim objolecon As OleDbConnection
Dim objcmd As OleDbCommand
Dim strsql, strcon As String
Dim count As Integer strcon = "Provider = Microsoft.Jet.OLEDB.4.0;" & "data source =../../welding.mdb"
'If userNameBoolean = True And passwordBoolean = True Then
If Tablename = "teacher" Then
strsql = "insert into [Teacher](TeacherName,TeacherCode)values('" & userName & "','" & Password & "')" '加入教师姓名、密码
Else
strsql = "insert into [Student](StudentName,StudentCode)values('" & userName & "','" & Password & "')" '加入学生姓名、密码 End If
'End If
objolecon = New OleDbConnection(strcon)
objolecon.Open()
objcmd = New OleDbCommand(strsql, objolecon) count = objcmd.ExecuteNonQuery()
If count = 1 Then
MessageBox.Show("添加记录成功,请联系管理员对数据进行完善!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("添加记录失败,请重新注册!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning) End If
刚接触,怎么放到access里运行啊?