postgresql - 我在将数据插入到 postgres 表单 Visual basic.Net 时遇到问题
问题描述
这是我的功能
公共函数 AgregarDempartmento(ByVal ldepartamento 作为 LDepartamento) 作为布尔尝试 conectar() 将 cmd 作为新的 Npgsql.NpgsqlCommand("sp_agregar_departamento;", con)
cmd.CommandType = CommandType.StoredProcedure
With cmd.Parameters
.Add(":puestoP", NpgsqlTypes.NpgsqlDbType.Varchar).DataTypeName = ldepartamento._puesto
.Add(":departamentoP", NpgsqlTypes.NpgsqlDbType.Varchar).DataTypeName = ldepartamento._departamento
End With
If cmd.ExecuteNonQuery Then
Return True
Else
Return False
End If
Catch ex As Exception
MsgBox(ex.Message)
Return False
Finally
desconectar()
End Try
End Function
我这样设置 Public Class LDepartamento Dim iddepartamento As Integer Dim puesto, departamento As String
Public Property _iddepartamento
Set(value)
iddepartamento = value
End Set
Get
Return iddepartamento
End Get
End Property
Public Property _puesto
Set(value)
puesto = value
End Set
Get
Return puesto
End Get
End Property
Public Property _departamento
Set(value)
departamento = value
End Set
Get
Return departamento
End Get
End Property
结束类
这就是我从表单中插入的方式
Private Sub Agregar_Click(sender As Object, e As EventArgs) 处理 Agregar.Click
valores._puesto = txtpuesto.Text
valores._departamento = txtdepartamento.Text
If funciones.AgregarDempartmento(valores) Then
MsgBox("Departamento Agregada Correctamente", MsgBoxStyle.Information, "Registro de Departamento")
Me.Close()
Else
MsgBox("Departamento No Agregada Correctamente", MsgBoxStyle.Exclamation, "Registro de Departamento")
End If
MsgBox("Ingrese un departamento Correcta porfavor", MsgBoxStyle.Exclamation, "Registro de Departamento")
End Sub
解决方案
推荐阅读
- android-studio - Androidstudio 项目中的 Project.xml。这是源代码控制的一部分吗?
- ruby-on-rails - 在rails中创建belongs_to关联时1:整数的未定义方法`build_part'
- python - python pd.DataFrame({'Dokuman': docs, 'Sinif': classes}) 中的熊猫数据框问题
- git - git的文件写入(在工作目录中)是原子的吗?
- angular - 事件仅在第一次点击时触发 angular - 7
- python - 如何从类名中获取类对象
- vue.js - Vue Electron,开发工具抛出异常
- java - 如何创建具有正确宽度和高度的垂直标签?
- ios - 如何在返回 void 的函数之外获取视频数据?
- math - 获胜手型的扑克赔率计算