Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ExecuteScalar:Connection property has not been initialized

ExecuteScalar:Connection property has not been initialized

Scheduled Pinned Locked Moved ASP.NET
databasehelpannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    saravanan05
    wrote on last edited by
    #1

    hi friends this is my function: Function GetRedPlayer() As String Dim dt As New DataTable Dim i As Integer Dim dt1 As New DataTable Dim j As Integer Dim flag As Boolean = False Dim sessonid As Integer = UserInfo.GetCurrentSeasonid() Dim sqlquery As String = "select tavernid from tavern where paid=0" dt = DBManager.GetDataTable(sqlquery) If dt.Rows.Count > 0 Then 'Get tavernid For i = 0 To dt.Rows.Count - 1 Dim Tv_id = dt.Rows(i)("tavernid").ToString() '14 days current date Dim For14GetDate As String = DateTime.Now.AddDays(-14).ToString() Dim For14daysCurrentdate As String = For14GetDate.Substring(0, 9) 'current date Dim GetDate As String = DateTime.Now.ToString() Dim Currentdate As String = GetDate.Substring(0, 9) Dim sqlqueryGetplayerid As String = "select Eventid from pokerevents where tavernid=" & Tv_id & " and seasonid = " & sessonid & " And tournamentdate >" & For14daysCurrentdate & " And tournamentdate <= '" & Currentdate & "'" dt1 = DBManager.GetDataTable(sqlqueryGetplayerid) If dt1.Rows.Count > 0 Then For j = 0 To dt1.Rows.Count - 1 'Get eventid Dim Ev_id = dt1.Rows(j)("eventid").ToString() Dim StrScoreQuery As String = "Select points from scores where eventid=" & Ev_id & "" Dim retVal As Int64 = DBManager.GetScalar(StrScoreQuery) If flag = False Then 'begin flag If retVal = -2 Then flag = True Dim SqlQueryGettavernID As String = "select tav.tavernid as tavernid from tavern tav join pokerevents pe on tav.tavernid=pe.tavernid where pe.eventid =" & Ev_id & "" Dim TavidIsred As Integer = DBManager.GetScalar(SqlQueryGettavernID) Dim updateQueryForRed As String = "update tavern set Isred=" & 0 & " where tavernid=" & TavidIsred & "" DBManager.GetNameValueColl(updateQueryForRed) Else Dim SqlQueryGettavernIDForNotRed As String = "select tav.tavernid as tavernid from tavern tav join pokerevents pe on tav.tavernid=pe.tavernid where pe.eventid =" & Ev_id & "" Dim TavidIsnotred As Integer = DBManager.GetScalar(SqlQueryGettavernIDForNotRed) Dim updateQueryForNotRed As String = "update tavern set Isred=" & 1 & " where tavernid=" & TavidIsnotred & "" DBManager.GetNameValueColl(updateQueryForNotRed) End If End If ' End flag Next End If Next End If End Function here i get near 5500 record in datatable and looping through that time i got error "ExecuteScalar:Connection property has not been initialized" like this in below function Getscalr function: Shared Function GetScalar(ByVal query As String) As Int64 Dim myconnGS As New OdbcConne

    S 1 Reply Last reply
    0
    • S saravanan05

      hi friends this is my function: Function GetRedPlayer() As String Dim dt As New DataTable Dim i As Integer Dim dt1 As New DataTable Dim j As Integer Dim flag As Boolean = False Dim sessonid As Integer = UserInfo.GetCurrentSeasonid() Dim sqlquery As String = "select tavernid from tavern where paid=0" dt = DBManager.GetDataTable(sqlquery) If dt.Rows.Count > 0 Then 'Get tavernid For i = 0 To dt.Rows.Count - 1 Dim Tv_id = dt.Rows(i)("tavernid").ToString() '14 days current date Dim For14GetDate As String = DateTime.Now.AddDays(-14).ToString() Dim For14daysCurrentdate As String = For14GetDate.Substring(0, 9) 'current date Dim GetDate As String = DateTime.Now.ToString() Dim Currentdate As String = GetDate.Substring(0, 9) Dim sqlqueryGetplayerid As String = "select Eventid from pokerevents where tavernid=" & Tv_id & " and seasonid = " & sessonid & " And tournamentdate >" & For14daysCurrentdate & " And tournamentdate <= '" & Currentdate & "'" dt1 = DBManager.GetDataTable(sqlqueryGetplayerid) If dt1.Rows.Count > 0 Then For j = 0 To dt1.Rows.Count - 1 'Get eventid Dim Ev_id = dt1.Rows(j)("eventid").ToString() Dim StrScoreQuery As String = "Select points from scores where eventid=" & Ev_id & "" Dim retVal As Int64 = DBManager.GetScalar(StrScoreQuery) If flag = False Then 'begin flag If retVal = -2 Then flag = True Dim SqlQueryGettavernID As String = "select tav.tavernid as tavernid from tavern tav join pokerevents pe on tav.tavernid=pe.tavernid where pe.eventid =" & Ev_id & "" Dim TavidIsred As Integer = DBManager.GetScalar(SqlQueryGettavernID) Dim updateQueryForRed As String = "update tavern set Isred=" & 0 & " where tavernid=" & TavidIsred & "" DBManager.GetNameValueColl(updateQueryForRed) Else Dim SqlQueryGettavernIDForNotRed As String = "select tav.tavernid as tavernid from tavern tav join pokerevents pe on tav.tavernid=pe.tavernid where pe.eventid =" & Ev_id & "" Dim TavidIsnotred As Integer = DBManager.GetScalar(SqlQueryGettavernIDForNotRed) Dim updateQueryForNotRed As String = "update tavern set Isred=" & 1 & " where tavernid=" & TavidIsnotred & "" DBManager.GetNameValueColl(updateQueryForNotRed) End If End If ' End flag Next End If Next End If End Function here i get near 5500 record in datatable and looping through that time i got error "ExecuteScalar:Connection property has not been initialized" like this in below function Getscalr function: Shared Function GetScalar(ByVal query As String) As Int64 Dim myconnGS As New OdbcConne

      S Offline
      S Offline
      SayreCC
      wrote on last edited by
      #2

      Hi, try this Shared Function GetScalar(ByVal query As String) As Int64 Dim r as Int32 Dim myconnGS As New OdbcConnection Dim mycmdGS As New OdbcCommand myconnGS = getConnection() mycmdGS = New OdbcCommand(query, myconnGS) r = mycmdGS.ExecuteScalar()//here i got the error mycmdGS.Close() Return GetScalar End Function Hope this one can help. Thanks

      S 1 Reply Last reply
      0
      • S SayreCC

        Hi, try this Shared Function GetScalar(ByVal query As String) As Int64 Dim r as Int32 Dim myconnGS As New OdbcConnection Dim mycmdGS As New OdbcCommand myconnGS = getConnection() mycmdGS = New OdbcCommand(query, myconnGS) r = mycmdGS.ExecuteScalar()//here i got the error mycmdGS.Close() Return GetScalar End Function Hope this one can help. Thanks

        S Offline
        S Offline
        saravanan05
        wrote on last edited by
        #3

        thanks for reply but same error occured

        Known Is Drop.Unknown Is Ocean

        S 1 Reply Last reply
        0
        • S saravanan05

          thanks for reply but same error occured

          Known Is Drop.Unknown Is Ocean

          S Offline
          S Offline
          SayreCC
          wrote on last edited by
          #4

          Hi, can u post the error?

          S 1 Reply Last reply
          0
          • S SayreCC

            Hi, can u post the error?

            S Offline
            S Offline
            saravanan05
            wrote on last edited by
            #5

            ExecuteScalar:Connection property has not been initialized

            Known Is Drop.Unknown Is Ocean

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups