-1
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim id As String, sLogon_User As String, sAuth_User As String, sUser_ID As String
    Dim sServer_Name As String
    Dim sIP_Address As String
    sIP_Address = Request.ServerVariables("REMOTE_ADDR")


    Dim hit As New PagePosting
    Dim currentPosting As Posting = CmsHttpContext.Current.Posting

    Dim webContext As WebAuthorContext
    webContext = WebAuthorContext.Current

    'sNama_Perusahaan = Request.QueryString("sentraID")
    'Response.Write("masuk sini dgn nilai = " & CmsHttpContext.Current.CmsQueryString())
    sData = ""
    If Not Page.IsPostBack Then


        'sNama_Perusahaan = Request.ServerVariables("sentraID")
        sNama_Perusahaan = Request.QueryString("sentraID")
        '  sNama_Perusahaan = Request.QueryString("sentraID")
        Response.Write("masuk sini dgn nilai = " & Request.QueryString("sentraID") & sNama_Perusahaan)
        tampil(sNama_Perusahaan)


    End If



Sub tampil(ByVal sParam As String)

    Dim rd As SqlDataReader
    Dim myConnection = New SqlConnection(ConfigurationSettings.AppSettings("RegBIK"))
    myConnection.Open()

    Dim adadata As Integer

    '   Dim myCommand As New SqlCommand("select count (*)  from kuesioner where ltrim(rtrim(NmPerush)) ='aaa'", myConnection)
    Dim myCommand As New SqlCommand("select count (*)  from kuesioner where ltrim(rtrim(NmPerush)) ='&sParam'", myConnection)

    rd = myCommand.ExecuteReader
    While rd.Read
        adadata = rd.GetInt32(0)
    End While


    myConnection.close()

    Try
        If adadata > 0 Then
            myConnection.Open()
            ' Dim myCommands As New SqlCommand("select * from kuesioner where ltrim(rtrim(NmPerush)) ='aaa'", myConnection)
            Dim myCommands As New SqlCommand("select * from kuesioner where ltrim(rtrim(NmPerush)) ='&sParam'", myConnection)

            rd = myCommands.ExecuteReader
            While rd.Read
                disabledAll()
                Me.btnUpload.Enabled = False
                Me.btnPreview.Enabled = True
                txtNmPerush.Value = rd.GetString(1)
                Me.txtNmPemilik.Value = rd.GetString(2)
                Me.txtAlmtPerush.Value = rd.GetString(3)
                Me.txttlpn.Value = rd.GetString(4)
                Me.txtEmail.Value = rd.GetString(5)
                Me.txtLamaPerush.Value = rd.GetString(6)
                Me.txtJenis.Value = rd.GetString(7)
                Me.txtSpesialisasi.Value = rd.GetString(8)
                Me.txtkualitas.Value = rd.GetString(9)
                Me.txtMerk.Value = rd.GetString(10)
                Me.txtStandarPesanan.Value = rd.GetString(11)
                Me.txtProduksi.Value = rd.GetString(12)
                Me.txtlokal.Value = rd.GetString(13)
                Me.txtnasional.Value = rd.GetString(14)
                Me.txtekspor.Value = rd.GetString(15)
                Me.txtpengalaman.Value = rd.GetString(16)
                Me.txtlamaekspor.Value = rd.GetString(17)
                Me.txtbiaya.Value = rd.GetString(18)

            End While
        Else
            clearAll()

        End If
        rd.Close()
        myConnection.close()

    Catch SQLexc As SqlException

        Response.Write("Open Failed. Error Details are: " & SQLexc.ToString())
    End Try



End Sub

最初のパラメータを取得するためのソースコード、フォーム2にコーディングパラメータをスローするための2番目、フォーム2で読み取るための3番目のコーディング..試してみましたが、まだできません

4

1 に答える 1

0

そのコードはエラーを生成すると思いますが、あなたはそれを述べていませんでした。

パラメータをSQL文に追加するには:

Dim myCommand As New SqlCommand("SELECT COUNT(*) FROM kuesioner WHERE LTRIM(RTRIM(NmPerush)) = @param1", myConnection)

myCommand.Parameters.Add(New SqlParameter With {.ParameterName = "param1", _
                                                .SqlDbType = SqlDbType.NVarChar, _
                                                .Size = 200, _
                                                .Value = sParam})

.SqlDbType と .Size を変更して、データベースの定義と一致させてください。

于 2013-08-14T17:05:52.357 に答える