带有odbc错误的参数

时间:2016-02-26 03:05:08

标签: sql sql-server vb.net odbc

我对使用odbc存储过程的供应参数存在问题,这是module form Public cmd As OdbcCommand

中的程序
Private Sub cmdapprove_Click(sender As Object, e As EventArgs) Handles cmdapprove.Click
    cmd = New OdbcCommand("select * from mk_cuti where mk_nik='" & txtnik.Text & "'", conn)
    rd = cmd.ExecuteReader
    rd.Read()
    rd.Close()
    Call opendb()
    If txtstatus.Text = 1 Then
        Using (conn)
            cmd.Connection = conn
            cmd.CommandType = CommandType.StoredProcedure
            cmd.CommandText = "sp_update_data_trans_cuti_terbawa"
            cmd.Parameters.AddWithValue("@mk_nik", Me.txtnik.Text)
            cmd.ExecuteNonQuery()
        End Using

        Dim updatestatus_hrd As String = "Update input_cuti set status_hrd=1 " & _
        "where no_input='" & txtnoinput.Text & "'"
        cmd = New OdbcCommand(updatestatus_hrd, conn)
        cmd.ExecuteNonQuery()
        Call datacutikaryawan()
    Else
        Dim updatestatus_hrd As String = "Update input_cuti set status_hrd=1 " & _
        "where no_input='" & txtnoinput.Text & "'"
        cmd = New OdbcCommand(updatestatus_hrd, conn)
        cmd.ExecuteNonQuery()
        Call datacutikaryawan()
    End If

End Sub

当我运行这个程序时,我得到了按摩

  

错误[42000] [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]过程   或函数'sp_update_data_trans_cuti_terbawa'需要参数   '@mk_nik',未提供。

我想有人可以帮助我吗?请

3 个答案:

答案 0 :(得分:0)

conn.execute("sp_update_data_trans_cuti_terbawa @mk_nik='" & Me.txtnik.Text & "'")

答案 1 :(得分:0)

我有这个模块

导入System.Data.Odbc 导入System.Data 模块koneksi     Public conn As OdbcConnection     Public str As String     Public da As OdbcDataAdapter     Public ds As DataSet     Public cmd As OdbcCommand     Public rd As OdbcDataReader

Sub opendb()
    str = "Dsn=pmscuti;database=att2000;server=pams-01;uid=sa;pwd=pams123"
    conn = New OdbcConnection(str)
    If conn.State = ConnectionState.Closed Then
        Try
            conn.Open()
            'MsgBox("Connection Successfully")
        Catch ex As Exception
            MsgBox(ex.Message)
            Application.Exit()

        End Try
    End If
End Sub

结束模块

我可以知道问题出在哪里吗?

答案 2 :(得分:0)

这是你班上的一个:

Cell.backGroundImage.contentMode = UIViewContentModeScaleAspectFill;

Aight,我去了最近的酒吧。