【发布时间】:2021-02-16 12:56:50
【问题描述】:
private Sub Button1_Click(ByVal sender As System. Object, ByVal e As System.EventArgs) Handles Button1.Click
If conn.State = ConnectionState.Open Then
conn.Close()
End If
If Trim(txtcode.Text) = "" Then
MsgBox("Please enter the unique Member code")
txtcode.Focus()
Exit Sub
ElseIf IsNumeric(txtName_Surname.Text) Then
MsgBox("Please replace numbers with text", MessageBoxIcon.Stop)
txtName_Surname.Focus()
Exit Sub
Else
Try
Dim strinsert As String
Dim cmdinsert As OleDb.OleDbCommand
Dim Passport As String = Application.ExecutablePath
strinsert = "insert into book_mast (Mem_code,Name_Surname,Date_of_Birth,Gender,Telephone_number,Age,Status,Date_of_Baptism,House_No,Occupation,Education,Office_Name,Tel,Office_No,Tithe_per_month,Total_tithe_per_year,Born_Again,BA_Time,Baptizism,Baptizism_where,Join_RCCG,Join_Where,Baptizism_Ghost,BPG_When,Tongues,Tongues_When, Passport) values(@txtcode, @txtName_Surname, @d1, @txtgen, @txtTelephone_number, @txtage, @CbBStatus, @d2, @txthno, @TxtOccupation, @CbBEducation, @TxtOffName, @TxtTel, @txtOno, @txtTithe_per_month, @txtTotal_tithe_per_year, @TxtBornAgain, @TxtBornwhen, @CbBbaptizism, @TxtBaptizedwhere, @TxtJoinRCCG, @TxtJoinWhere, @TxtHolyGhost, @TxtGhostWhen, @TxtTongues, @TxtTonguesWhen, @Passport)"
cmdinsert = New OleDb.OleDbCommand(strinsert, conn)
conn.Open()
cmdinsert.ExecuteNonQuery()
MsgBox("Record Has been added Successfully")
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.Close()
clearall()
fillgridmem()
End Try
End If
End Sub
【问题讨论】:
-
你能澄清一下问题到底是什么,以便我可以帮助并尝试编辑问题并将 vb 代码包装在“{}”中,如果代码出现任何错误。
-
请重新格式化,使其更易于阅读
-
我看不到您在哪里为参数赋值。
-
我没有看到任何努力来保存
Image那么实际问题是什么?如果您在网上搜索如何将Image保存到数据库中,那么您会发现大量信息,因此至少没有理由不尝试。 -
不要;将其保存到磁盘文件系统并将文件路径放入数据库中