Incorrect syntax near '&'.

กระทู้คำถาม
Private Sub showData()


        Dim s As String = "Select Top 1 Bill_id,Pa_id,med_id from Bill where Bill_id =  & Bill_id"

        da = New SqlDataAdapter(s, cn)
        ds = New DataSet
          da.Fill(ds, "B")<<<<ตรงนี้มันขึ้นคำว่าคะ  Incorrect syntax near '&'.
        'Da2.DataSource = ds
        'Da2.DataMember = "B"
        'Da2.ReadOnly = True
        'Da2.ReadOnly = True
        If ds.Tables("B").Rows.Count > 0 Then
            txtBillID.Text = (CInt(ds.Tables("B").Rows(0)("Bill_ID").ToString())).ToString("00000")
        Else
            txtBillID.Text = "00001"
        End If

        'With .Da2
        '    If .RowCount > 0 Then
        '        .ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
        '        .Columns(0).HeaderText = "รหัสยา"
        '        .Columns(1).HeaderText = "ชื่อยา"
        '        .Columns(6).HeaderText = "ราคา"
        '         Columns(6).HeaderText = "จำนวน"
        '        .Columns(7).HeaderText = "ยอดรวม"

        '    End If
        '    With cn
        '        If .State = ConnectionState.Open Then .Close()
        '        .ConnectionString = strconn
        '        .Open()
        '    End With


        'End With

        s = "select * from unit"
        da = New SqlDataAdapter(s, cn)
        da.Fill(ds, "unit")


        s = "select * from patient"
        da = New SqlDataAdapter(s, cn)
        da.Fill(ds, "Patient")

        CmbPatient.DataSource = ds.Tables("Patient")
        CmbPatient.DisplayMember = "Pa_id"
        CmbPatient.ValueMember = "Pa_id"
        CmbPatient.SelectedValue = ((ds.Tables("B").Rows(0)("Pa_id").ToString()))


        s = "select * from Medicine"
        da = New SqlDataAdapter(s, cn)
        da.Fill(ds, "Medicine")
        CmbDrug.DataSource = ds.Tables("Medicine")
        CmbDrug.DisplayMember = "Med_id"
        CmbDrug.ValueMember = "Med_id"
        CmbDrug.SelectedValue = ""
        For i As Integer = 1 To 20
            cmbQuantity.Items.Add(i)
        Next
        cmbQuantity.SelectedIndex = 0

        cmbQuantity.DropDownStyle = ComboBoxStyle.DropDownList
        CmbPatient.DropDownStyle = ComboBoxStyle.DropDownList
        CmbDrug.DropDownStyle = ComboBoxStyle.DropDownList
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่