在座的每一个人,一直都是那么大的帮助,无论是直接的还是间接的。寄希望于这再次成为现实。
为澄清起见,存储过程在 FireBird 下运行,而 VB 属于 .NET 变体
我有一个存储过程(摘录如下,重要的是 WHERE)
select pn, pnm.description, si_number, entry_date, cmp_auto_key,
parts_flat_price, labor_flat_price, misc_flat_price, woo_auto_key,
wwt_auto_key
from parts_master pnm, wo_operation woo
where pn like :i_pn || '%'
and pnm.pnm_auto_key = woo.pnm_auto_key
into :pn, :description, :work_order, :entry_date, :cmp, :parts_price,
:labor_price, :misc_price, :woo, :wwt
我正在尝试从使用参数 I_PN 的 vb 应用程序传递参数,其代码如下(MyServer 和 MyPassword 的变量由代码的早期部分确定。)
Try
Dim FBConn As New FirebirdSql.Data.FirebirdClient.FbConnection()
Dim FBCmd As FirebirdSql.Data.FirebirdClient.FbCommand
Dim MyConnectionString As String
MyConnectionString = _
"datasource=" & MyServer & ";database=" & TextBox4.Text & "; & _
user id=SYSDBA;password=" & MyPassword & ";initial catalog=;"
FBConn = New FirebirdSql.Data.FirebirdClient. & _
FbConnection(MyConnectionString)
FBConn.Open()
FBConn.CreateCommand.CommandType = CommandType.StoredProcedure
FBCmd = New FirebirdSql.Data.FirebirdClient. & _
FbCommand("WIP_COSTS", FBConn)
FBCmd.CommandText = "WIP_COSTS"
FBConn.CreateCommand.Parameters. & _
Add("@I_PN", FirebirdSql.Data.FirebirdClient.FbDbType.Text). & _
Value = TextBox1.Text
Dim I_PN As Object = New Object()
Me.WIP_COSTSTableAdapter.Fill(Me.WOCostDataSet.WIP_COSTS, @I_PN)
FBConn.Close()
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
当我执行 VB.App 并尝试运行程序时,我收到以下错误:
动态 SQL 错误
SQL 错误代码 = -206
Column Unknown
I_PN
At Line 1, column 29
而且我不能完全确定实际问题是什么。意思是,我不知道我的逻辑是否在 VB 端或存储过程中不正确。
包含的任何编码都是从我发现的示例中与在 GoogleFu 长期逗留期间发现的各种代码位一起拼凑而成的。
任何拥有超过一两个月的 VB 经验(不像我)的人都可以只看一眼就可以证明——我的代码可能很糟糕而且格式不正确——当然不优雅,而且在操作上最有把握。我当然会张开双臂接受各种建议。
像往常一样,如果您还有其他问题,我会尽我所能回答。
再次感谢。
雅苏米安