none
Script Search Record tidak jalan

    Pertanyaan

  • Public Class roomList
    #Region "Koneksi Database"
      Private dtadapter As SqlDataAdapter = Nothing
      Dim koneksi As New SqlConnection("server=ACER-PC\SQLEXPRESS; database=mydbhotel;")
      Dim comSql As SqlCommand
      Dim dtview As DataView
      Dim posisi As Integer
    #End Region
    #Region "GuestList"
      Sub SearchRecord()
        If TextBox1.Text = "" Then
          MsgBox("Please Insert The Key", MsgBoxStyle.Information, "Searching Record")
          TextBox1.Focus()
          Exit Sub
        End If
    
        Try
          If rdoname.Checked = True Then
            dtadapter = New SqlDataAdapter("select firstname as [First Name],lastname as [Last Name], address as [Address], country as [Country], company as [Company], datein as [Date In], dateout as [Date Out], note as [Note] from tcekin Where fistname = '" & TextBox1.Text & "'", koneksi)
          Else
            dtadapter = New SqlDataAdapter("select firstname as [First Name],lastname as [Last Name], address as [Address], country as [Country], company as [Company], datein as [Date In], dateout as [Date Out], note as [Note] from tcekin Where company = '" & TextBox1.Text & "%'", koneksi)
          End If
    
          Dim tcekin As New DataTable
          tcekin.Clear()
          dtadapter.Fill(tcekin)
          If tcekin.Rows.Count = Nothing Then
            MsgBox("Data Not Found", MsgBoxStyle.Information, "Attention")
            TextBox1.Clear()
            TextBox1.Focus()
            Exit Sub
          End If
    
        Catch ex As SqlException
          MsgBox(ex.Message, MsgBoxStyle.Information, "Attention")
        End Try
      End Sub
    #End Region
    
      Private Sub roomList_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MydbhotelDataSet.tcekin' table. You can move, or remove it, as needed.
        Me.TcekinTableAdapter.Fill(Me.MydbhotelDataSet.tcekin)
    
    
      End Sub

    halo, saya ada mau tanya diatas script yg saya buat untuk mencari record db. jadi saya ada baut program make vb.net dan jika saya ingin mencari berdasarkan nama maka saya pilih radiobutton Name, tetapi ketika saya klik button search, malah ngk jalan.

     

    tolong donk bantuin saya


    kosong dulu ya
    23 Nopember 2010 13:15

Semua Balasan

  • Mas, Dot_co_id,

    bila saya perhatikan tampak ada kesalahan penulisan T-SQL disini :

    select firstname as [First Name],lastname as [Last Name], address as [Address], country as [Country], company as [Company], datein as [Date In], dateout as [Date Out], note as [Note] from tcekin Where fistname =

    tampak pada penulisan filter FIRSTNAME ditulis menjadi FISTNAME, padahal pada pemanggilan di SELECT menggunakan FIRSTNAME.

    Sepertinya filter field yang digunakan tidak ada yang memiliki field bernama FISTNAME.

    Demikian semoga membantu.


    Regards,
    Suherman
    Profile : MVP Profile
    Blog : Microsoft User Group Indonesia
    Mohon klik tombol "Ajukan Sebagai Jawaban" jika menurut anda jawaban saya benar

    20 Februari 2013 2:56