mysql - Invalid Attempt to access field before read -
i have been beating head on morning , know it's simple thing i'm missing. code breaking @ dr.getstring(1).tostring line error "invalid attempt access field before calling read(). know sql statement works fine in workbench i'm thinking has messed parameter, it's not erroring out there.
dim cs new mysqlconnection("server=10.1.1.1;persist security info=true;database=db;uid=uid;password=pw") dim ds string = cs.datasource dim cn mysqlconnection = new mysqlconnection cn.connectionstring = "user id=uid;password=pw!;database=db;data source=" + ds dim sql string = "select a.email, b.details, b.requestor, b.id department a, workrequest b a.name = b.department , b.approval null , b.status != @stat" dim cmd new mysqlcommand(sql, cn) cmd.parameters.add("@stat", mysqldbtype.varchar).value = "closed" cn.open() dim dr mysqldatareader dr = cmd.executereader dim integer = 0 while dr.read() or < 20 'dim email string = dr.getstring(0).tostring dim email string = "test@dom.an" dim details string = dr.getstring(1).tostring dim requestor string = dr.getstring(2).tostring dim workid string = dr.getstring(3).tostring try sendsmtp("test.dom.am", email, "work request awaiting approval", "<body><b>work request number:</b> " & workid & "</br><b> referring to: </b></br> " & details & "</br><b>submitted by: </b> " & requestor & "</br> waiting approval. please go http://test.dom.an view , approve or deny request</body>", "test.dom.an", "") catch ex exception end try = + 1 end while me.close()
Comments
Post a Comment