문제

여기있는 모든 사람들은 항상 직간접 적으로 큰 도움이되었습니다. 그리고 그것은 다시 한 번, 다시 말하지만, 그것은 사실이 사실이라는 희망입니다.

설명을 위해 저장된 절차는 Firebird에서 실행되고 VB는 .NET Variety입니다.

저장된 절차가 있습니다 (아래에서 발췌, 중요한 비트는 어디에 있습니다)

  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

VB 앱에서 매개 변수를 전달하려고합니다. 매개 변수 i_pn을 사용하는 매개 변수 (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
열되지 않은 열
i_pn
1, 열 29에서

그리고 나는 실제 문제가 무엇인지에 대해 손가락을 넣을 수 없습니다. 즉, 내 논리가 VB 쪽에서 잘못되었는지 또는 저장된 절차에 있는지 모르겠습니다.

포함 된 코딩은 GoogleFu의 긴 체류 중에 발견 된 다양한 코드로 찾은 예에서 함께 모여 있습니다.

VB를 가진 한 달 또는 2 개 이상의 경험을 가진 사람은 단지 한 눈에 입증 할 수 있으므로 내 코드는 아마도 꽤 엉망이며 잘 형성되지 않았을 것입니다. 나는 팔을 벌려 모든 조언의 모든 맛을 즐겁게하고 있습니다.

평소와 같이, 추가 질문이 있으면 최선을 다해 답변하겠습니다.

다시 한 번 감사드립니다.

Jasoomian

도움이 되었습니까?

해결책

약간 다시 생각하고 조금 더 연구 한 후 마침내 코드가 작동했습니다.

        Try

        ' Code for checking server location and required credentials

        Dim FBConn As FbConnection
        ' Dim FBAdapter As FbDataAdapter
        Dim MyConnectionString As String

        MyConnectionString = "datasource=" _
                        & MyServer & ";database=" _
                        & TextBox4.Text & ";user id=SYSDBA;password=" _
                        & MyPassword & ";initial catalog=;Charset=NONE"

        FBConn = New FbConnection(MyConnectionString)
        Dim FBCmd As New FbCommand("WIP_COSTS", FBConn)

        FBCmd.CommandType = CommandType.StoredProcedure
        FBCmd.Parameters.Add("@I_PN", FbDbType.VarChar, 40)
        FBCmd.Parameters("@I_PN").Value = TextBox1.Text.ToUpper


        Dim FBadapter As New FbDataAdapter(FBCmd)
        Dim dsResult As New DataSet
        FBadapter.Fill(dsResult)

        Me.WIP_COSTSDataGridView.DataSource = dsResult.Tables(0)

        Dim RecordCount As Integer
        RecordCount = Me.WIP_COSTSDataGridView.RowCount
        Label4.Text = RecordCount

    Catch ex As System.Exception
        System.Windows.Forms.MessageBox.Show _
        ("There was an error in generating the DataStream, " & _
        "please check the system credentials and try again. " &_ 
        "If the problem persists please contact your friendly " &_ 
        "local IT department.")
    End Try

    ' // end of line

또한 실제 저장된 절차를 변경해야한다고 생각했지만 이것은 잘못된 것으로 판명되었습니다.

코드는 예쁘지 않을 수 있으며, 더 나은 오류 처리를 위해 시도 블록에서 더 많은 작업을 수행해야합니다. 그러나 그것은 작동합니다.

삐걱 거리는 모든 분들께 감사드립니다.

다른 팁

이것을 바꾸십시오 :

FBConn.CreateCommand.Parameters. & _
        Add("@I_PN", FirebirdSql.Data.FirebirdClient.FbDbType.Text). & _
        Value = TextBox1.Text

... 이에:

FBCmd.Parameters.AddWithValue("@I_PN", TextBox1.Text)

기본적으로 연결 객체가 아닌 명령 개체에 저장된 프로 시저 매개 변수를 추가하려고합니다.

Andreik,

저장된 전체 절차는 다음과 같습니다. 그리고 우리의 파이어 버드는 버전 1.5.3, ibexpert 버전 2006.12.13, dialect 3으로 작성되었습니다.

Begin
For
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

Do begin
   labor_hours = null;
   work_type = null;
   parts_cost = null;
   labor_cost = null;
   ro_cost = null;
   customer = null;

   select company_name
     from companies
    where cmp_auto_key = :cmp
     into :customer;

   select work_type
     from wo_work_type
    where wwt_auto_key = :wwt
     into :work_type;

   select sum(sti.qty*stm.unit_cost)
     from stock_ti sti, stock stm, wo_bom wob
    where sti.wob_auto_key = wob.wob_auto_key
      and sti.stm_auto_key = stm.stm_auto_key
      and wob.woo_auto_key = :woo
      and sti.ti_type = 'I'
      and wob.activity <> 'Work Order'
      and wob.activity <> 'Repair'
     into :parts_cost;

   select sum(sti.qty*stm.unit_cost)
     from stock_ti sti, stock stm, wo_bom wob
    where sti.wob_auto_key = wob.wob_auto_key
      and sti.stm_auto_key = stm.stm_auto_key
      and wob.woo_auto_key = :woo
      and sti.ti_type = 'I'
      and wob.activity = 'Repair'
     into :ro_cost;

   select sum(wtl.hours*(wtl.fixed_overhead+wtl.variable_overhead+wtl.burden_rate)),
          sum(wtl.hours)
     from wo_task_labor wtl, wo_task wot
    where wtl.wot_auto_key = wot.wot_auto_key
      and wot.woo_auto_key = :woo
     into :labor_cost, :labor_hours;

   suspend;
   end
End

하드 코드 - 귀하의 제안에 대한 의견에 응답했습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top