Soru & Cevap

Incorrect syntax near the keyword user hatası visual studio

24.04.2020 - 04:03

Bu benim User.vb kodum

Imports System.Data.SqlClient

Public Class User
    Dim connect As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=model;Integrated Security=True")
    Private _username As String
    Private _sifre As String

    Public Property Username As String
        Get
            Return _username
        End Get
        Set(value As String)
            _username = value
        End Set
    End Property

    Public Property Sifre As String
        Get
            Return _sifre
        End Get
        Set(value As String)
            _sifre = value
        End Set
    End Property

    Sub KullaniciGirisi(kAdi As String, Password As String)
        Username = kAdi
        Sifre = Password

        If Username = "" Or Sifre = "" Then
            MessageBox.Show("Kullanıcı adı ve/veya şifre alanı boş geçilemez!", "Uyarı")
        Else
            If connect.State = ConnectionState.Closed Then
                connect.Open()
            End If
            Dim komut As New SqlCommand("select *from user where username='" & Username & "'", connect)
            Dim okuyucu As SqlDataReader = komut.ExecuteReader
            If okuyucu.Read Then
                If okuyucu(1) = Sifre Then
                    MessageBox.Show("İşlem Başarılı!", "Giriş Yapılıyor")
                    loginPage.clear()
                Else
                    MessageBox.Show("Şifrenizi kontrol ediniz!", "Uyarı")
                End If
            Else
                MessageBox.Show("Bilgilerinizi kontrol ediniz!", "Uyarı")
            End If

        End If
    End Sub
End Class

Bu da benim loginPage.vb kodum

Public Class loginPage
    Private Sub PictureBox1_Click(sender As Object, e As EventArgs)

    End Sub

    Private Sub lblKapat_Click(sender As Object, e As EventArgs) Handles lblKapat.Click
        Me.Close()

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnRegister.Click
        frmRegiter.ShowDialog()


    End Sub

    Private Sub btnhatirla_CheckedChanged(sender As Object, e As EventArgs) Handles btnhatirla.CheckedChanged

    End Sub

    Private Sub resetPassword_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles resetPassword.LinkClicked
        frmReset_password.ShowDialog()
    End Sub

    Private Sub password_TextChanged(sender As Object, e As EventArgs) Handles password.TextChanged

    End Sub

    Private Sub loginPage_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
    Dim K As New User
    Sub clear()
        For Each control As Control In Me.Controls
            If TypeOf control Is TextBox Then
                control.Text = ""

            End If
        Next

    End Sub
    Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click
        K.KullaniciGirisi(userName.Text, password.Text)
    End Sub
End Class

ClientConnectionId:54d7e125-c03a-40de-ae7e-b4cdf1fe1672
Error Number:156,State:1,Class:15</ExceptionString><DataItems><Data><Key>HelpLink.ProdName</Key><Value>Microsoft SQL Server</Value></Data><Data><Key>HelpLink.ProdVer</Key><Value>14.00.1000</Value></Data><Data><Key>HelpLink.EvtSrc</Key><Value>MSSQLServer</Value></Data><Data><Key>HelpLink.EvtID</Key><Value>156</Value></Data><Data><Key>HelpLink.BaseHelpUrl</Key><Value>http://go.microsoft.com/fwlink</Value></Data><Data><Key>HelpLink.LinkId</Key><Value>20476</Value></Data></DataItems></Exception></TraceRecord>
'System.Data.SqlClient.SqlException' türünde bir yakalanamayan özel durum, System.Data.dll öğesinde oluştu
Incorrect syntax near the keyword 'user'.

yukarıdaki de hata kodu

Dosyayı da alta koydum.

 

1,274 Görüntülenme

4 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user nilexa
nilexa
04.09.2022 - 10:32

Offering superior International cuisine, Keif’s successful restaurant branches are proof of a promising future! Find out more. lebanese restaurant dubai jumeirah

Profile picture for user nilexa
nilexa
03.09.2022 - 12:18

KEEP YOUR CATS HEALTHY, ACTIVE, &amp;amp; HAPPY   Cats are natural predators with an instinctual need to run, chase, hide, and play. Traditional cat beds are unappealing, unliked, and remain unused because they don’t support a cat’s true nature. The long-term effects of not having a proper outlet can lead to frustration an cat tunnel bed

picture-278842-1588255894.jpg
kaankaracan
26.04.2020 - 02:42

SQL Server Log kısmında Log File Viewer kısmından aldığınız hatayı bularak gerekli düzeltme işlemini belirlemeniz mümkün olabilir. Nasıl gidileceğine dair microsoft linki paylaşıyorum.

https://docs.microsoft.com/en-us/sql/relational-databases/performance/view-the-sql-server-error-log-sql-server-management-studio?view=sql-server-ver15

Profile picture for user eflasoft
eflasoft
24.04.2020 - 08:44

Merhabalar,

"user" rezerve edilmiş bir anahtar kelimedir.

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql?redirectedfrom=MSDN&view=sql-server-ver15

 

 Dim komut As New SqlCommand("select *from [user] where username='" & Username & "'", connect)

Üstteki gibi "user"ı köşeli parantezlerin içine yazarak deneyin.