i have 2 problem with my program when i wanna read data from sql server. my problem
- when i wanna read data type varchar from sql server 2008 r2 got error like this http://prntscr.com/apni8g and when i read data type integer from sql no error.
my code
<WebMethod()> _
Public Function TopKill() As Integer
Dim con As New SqlConnection
con.ConnectionString = "Data Source=127.0.0.1;Initial Catalog=RF_World;Integrated Security=True"
Dim killing As String
con.Open()
Dim cmd As New SqlCommand(("SELECT TOP 20 Name 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
End If
con.Close()
Return killing
End Function ' TOP 20 Killer
- when i read 2 data integer why output only one like this http://prntscr.com/apnjnk
my code
<WebMethod()> _
Public Function TopKill() As Integer
Dim con As New SqlConnection
con.ConnectionString = "Data Source=127.0.0.1;Initial Catalog=RF_World;Integrated Security=True"
Dim killing As String
con.Open()
Dim cmd As New SqlCommand(("SELECT TOP 20 [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("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. i realy need help to fix my code. maybe anyone can help me to fix my code
thanks before