我在放置Try
If TextBox1.Text = Nothing Or TextBox2.Text = Nothing Or TextBox3.Text = Nothing Or TextBox4.Text = Nothing Or TextBox5.Text = Nothing Or TextBox6.Text = Nothing Or TextBox7.Text = Nothing Or TextBox8.Text = Nothing Or ComboBox1.Text = Nothing Then
MsgBox("please complete the fields!", MsgBoxStyle.Critical)
Else
MysqlConn.Open()
command.Connection = MysqlConn
command.CommandType = CommandType.Text
command.CommandText = "SELECT * FROM customer WHERE email = @email"
READER = command.ExecuteReader
If READER.HasRows Then
MsgBox("e-mail is already in use!", MsgBoxStyle.Critical)
MysqlConn.Close()
Else
If Not READER.IsClosed Then
READER.Close()
End If
command.Connection = MysqlConn
command.CommandType = CommandType.Text
command.CommandText = "INSERT INTO customer (`username`, `firstname`, `lastname`, `password`, `confirmpass`, `securityq`, `securitya`, `gender`, `email`, `contactno`) VALUES (@uname,@fname,@lname,@pword,@confirm,@secuq,@secuqa,@gender,@email,@contactno)"
With command.Parameters
.AddWithValue("@uname", TextBox1.Text)
.AddWithValue("@fname", TextBox2.Text)
.AddWithValue("@lname", TextBox3.Text)
.AddWithValue("@pword", TextBox4.Text)
.AddWithValue("@confirm", TextBox5.Text)
.AddWithValue("@secuq", ComboBox1.SelectedItem)
.AddWithValue("@secuqa", TextBox6.Text)
If RadioButton1.Checked Then
.AddWithValue("@gender", "male")
ElseIf RadioButton2.Checked Then
.AddWithValue("@gender", "female")
End If
.AddWithValue("@email", TextBox7.Text)
.AddWithValue("@contactno", TextBox8.Text)
End With
command.ExecuteNonQuery()
MsgBox("Registration done!", MsgBoxStyle.OkOnly)
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
RadioButton1.Checked = False
RadioButton2.Checked = False
TextBox7.Clear()
TextBox8.Clear()
ComboBox1.ResetText()
Form1.Show()
Hide()
MysqlConn.Close()
End If
End If
Catch ex As mysqlException
MessageBox.Show(ex.Message)
Finally
MysqlConn.Dispose()
End Try
时收到错误,但当我删除代码时
注册完成
但它没有在数据库中插入任何内容。
public static void setupUI(final View view, final Activity activity) {
if (view instanceof ViewGroup) {
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
Utils.hideSoftKeyboard(activity, view);
return false;
}
});
}
if (view instanceof ViewGroup) {
for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) {
View innerView = ((ViewGroup) view).getChildAt(i);
setupUI(innerView, activity);
}
}
}
public static void hideSoftKeyboard(Activity activity, View searchET) {
try {
InputMethodManager mgr = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.hideSoftInputFromWindow(searchET.getWindowToken(), 0);
} catch (Exception e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
如果您使用相同的命令对象,则在执行另一个命令之前,您需要关闭该阅读器:
self.theLabel.text = "desiredText"
self.theLabel.addImageWith(name: "nameOfImage", behindText: false)