简体   繁体   中英

Read Data From SQL using Webservice VB.NET

i have a program to read data from sql server using vb .net web service but i have an error when i run my code like this

http://prntscr.com/apmahp

my code

<WebMethod()> _
Public Function TopKill() As Integer
    Dim con As New SqlConnection
    con.ConnectionString = "Data Source=127.0.0.1;Initial Catalog=RF_User;Integrated Security=True"
    Dim killing As Integer
    con.Open()
    Dim cmd As New SqlCommand(("SELECT TOP 20 Name, [Kill], Death FROM tbl_pvporderview  Join(tbl_base) ON tbl_pvporderview.serial = tbl_base.Serial ORDER BY [Kill] DESC"), con)
    Dim killreader As SqlDataReader
    killreader = cmd.ExecuteReader()
    killreader.Read()
    If killreader.HasRows Then
        killing = killreader.Item("Name").ToString
        killing = killreader.Item("Kill").ToString
        killing = killreader.Item("Death").ToString
    End If
    con.Close()
    Return killing
End Function ' TOP 20 Killer

i don't know how to fix it. any one can help me to fix my code

thanks before

Mind the spaces, use the edited query below

Dim cmd As New SqlCommand(("SELECT TOP 20 Name, [Kill], Death FROM tbl_pvporderview  Join tbl_base ON tbl_pvporderview.serial = tbl_base.Serial ORDER BY [Kill] DESC"), con)

This should work because there was a space missing after the Join

在此处输入图片说明

Hope this helped

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM