我的 into 语句错误有修复吗?
这是我的代码
Private Sub Guna2Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Guna2Button1.Click
Dim pop As OpenFileDialog = New OpenFileDialog
If pop.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
Guna2CirclePictureBox1.Image = Image.FromFile(pop.FileName)
End If
End Sub
Sub save()
Try
conn.Open()
Dim cmd As New OleDb.OleDbCommand("insert into Table1('firstname','lastname','username','password','dob','role','status','pic') values(@firstname,@lastname,@username,@password,@dob,@role,@status,@pic)", conn)
Dim i As New Integer
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@firstname", Guna2TextBox1.Text)
cmd.Parameters.AddWithValue("@lastname", Guna2TextBox2.Text)
cmd.Parameters.AddWithValue("@username", Guna2TextBox3.Text)
cmd.Parameters.AddWithValue("@password", Guna2TextBox4.Text)
cmd.Parameters.AddWithValue("@dob", CDate(Guna2DateTimePicker1.Value))
cmd.Parameters.AddWithValue("@role", Guna2ComboBox1.Text)
cmd.Parameters.AddWithValue("@status", CBool(Guna2CheckBox2.Checked.ToString))
'image convert to binary formate
Dim FileSize As UInt32
Dim mstream As New System.IO.MemoryStream
Guna2CirclePictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim picture() As Byte = mstream.GetBuffer
FileSize = mstream.Length
mstream.Close()
cmd.Parameters.AddWithValue("@pic", picture)
i = cmd.ExecuteNonQuery
If i > 0 Then
MsgBox("You are now a registered member.", vbInformation)
Else
MsgBox("Registration Failed. Try Again.", vbCritical)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
,它说正确输入“名字”,但我做到了。它也是我的access数据库中相同的字段名称。我希望你能帮助我解决我的问题。我保证会做出回应。谢谢。
This is my code
Private Sub Guna2Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Guna2Button1.Click
Dim pop As OpenFileDialog = New OpenFileDialog
If pop.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
Guna2CirclePictureBox1.Image = Image.FromFile(pop.FileName)
End If
End Sub
Sub save()
Try
conn.Open()
Dim cmd As New OleDb.OleDbCommand("insert into Table1('firstname','lastname','username','password','dob','role','status','pic') values(@firstname,@lastname,@username,@password,@dob,@role,@status,@pic)", conn)
Dim i As New Integer
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@firstname", Guna2TextBox1.Text)
cmd.Parameters.AddWithValue("@lastname", Guna2TextBox2.Text)
cmd.Parameters.AddWithValue("@username", Guna2TextBox3.Text)
cmd.Parameters.AddWithValue("@password", Guna2TextBox4.Text)
cmd.Parameters.AddWithValue("@dob", CDate(Guna2DateTimePicker1.Value))
cmd.Parameters.AddWithValue("@role", Guna2ComboBox1.Text)
cmd.Parameters.AddWithValue("@status", CBool(Guna2CheckBox2.Checked.ToString))
'image convert to binary formate
Dim FileSize As UInt32
Dim mstream As New System.IO.MemoryStream
Guna2CirclePictureBox1.Image.Save(mstream, System.Drawing.Imaging.ImageFormat.Jpeg)
Dim picture() As Byte = mstream.GetBuffer
FileSize = mstream.Length
mstream.Close()
cmd.Parameters.AddWithValue("@pic", picture)
i = cmd.ExecuteNonQuery
If i > 0 Then
MsgBox("You are now a registered member.", vbInformation)
Else
MsgBox("Registration Failed. Try Again.", vbCritical)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
conn.Close()
End Sub
It says type "firstname" correctly but I did. It is also the same field name in my access database. I hope you could help me with my problem. I promise to be responsive. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另外,Password 是一个保留字:
并且 DateTimePicker 返回一个 DateTime 值:
Also, Password is a reserved word:
and DateTimePicker returns a DateTime value: