i'm attempting vb6 application written client decade back, intermittently keep getting error. application has login required upon launch, , upon entering login provided me (i 100% correct), following error given:
run-time error '3709'
requested operation requires ole db session object, not supported current provider.
what's bizarre last night able log in absolutely no problems. however, had problem before week back, out of town several days , when cam log in again. before initial instance, able log in fine. noticed similar question posted, solution given did not work me. here's code pertaining establishing database connection. note, serv1, use1, pw1 etc fillers server names/usernames/passwords.
public function getconnected() ' function decides server connect , makes connection 'determines connection string use if frmsplash.text1 = "1" or frmsplash.text1 = "apc" 'server location 'determines if logon contains '1' or 'apc' 'apc connection code strsqlservername = "(serv1)" strsqldbusername = "use1" strsqldbpassword = "pw1" strsqlport = "" elseif frmsplash.text1 = "2" 'laptop connection string strsqlservername = "(serv1)" strsqldbusername = "use2" strsqldbpassword = "pw2" strsqlport = "" else 'client connection code strsqlservername = "serv2 strsqldbusername = "use3" strsqldbpassword = "pw3" strsqlport = "" end if 'server location 'if (m_dbconnection nothing) set m_dbconnection = new adodb.connection 'end if sessionlocation = frmsplash.locationcombo.text '*************************************** 'connecs database based on location if frmsplash.locationcombo.text = "loc1" strsqldbname = "servloc1" elseif frmsplash.locationcombo.text = "loc2" strsqldbname = "servloc2" else strsqldbname = "servloc3" end if '************************** 'builds connection string m_dbconnection.connectionstring = "provider=sqloledb;" & _ "data source = '" & strsqlservername & strsqlport & "';" & _ "uid=" & strsqldbusername & ";" & _ "pwd=" & strsqldbpassword & ";" & _ "database=" & strsqldbname & ";" on error goto errorhandler m_dbconnection.open if (m_dbconnection nothing) msgbox "connection failed" end if exit function errorhandler: msgbox ("problem server") 'msgbox "connection state " & getstate(m_dbconnection.state) end function public function executesql(strsql string) adodb.recordset 'dim cmd adodb.command set cmd = new adodb.command **cmd.activeconnection = m_dbconnection** <-----(error occurs here) cmd.commandtype = adcmdtext cmd.commandtext = strsql set executesql = cmd.execute exit function
variable definitions:
public strsqlservername 'holds name of sql server public strsqldbusername 'holds user name (for sql server authentication) public strsqldbpassword 'holds password (for sql server authentication) public strsqldbname 'holds name of database on server public strsqlport 'holds port number public sessionuser integer ' track type of user (3 levels) public sessionlocation string ' track db throughout session public m_dbconnection adodb.connection public cmd adodb.command
this first time working in vb6 , i'm bit @ loss. can't figure out why works , not others. if has insights, they'd appreciated.
change error handling better idea of going on. since setting conncection (set m_dbconnection = new adodb.connection) new object, check (m_dbconnection nothing) doesn't since ojbect exist.
Comments
Post a Comment