c# - Cannot convert from 'void' to 'string' error message -


i trying app connect oracle database , found lovely tutorial here: tutorial here.

i not programmer, have plugged in program , getting error message

argument 1: cannot convert from'void' 'string'

in bit calling connect , query method. advice on how fix issue?

the problem when try call connectandquery method show results.

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; using system.data.oracleclient;  namespace sqlconnect3 { public partial class updateposnewuser : form {     int sum = 0;      public updateposnewuser()     {         initializecomponent();     }      private static string connection_string =         "user id=myuser;password=mypassword;data source=(description=" +         "(address=(protocol=tcp)(host=myhost)(port=myport))" +         "(connect_data=(sid=mysid)));";      // didn't need in own method, makes easier      // make changes if want try different things such     // promting user credentials, etc.      static private string getconnectionstring()     {         // avoid storing connection string in code,          // can retrieve configuration file.          return "data source=myserver.server.com;persist security info=true;"              +                "user id=myuserid;password=mypassword;unicode=true";     }      // open connection , query database     static private void connectandquery()     {         string connectionstring = getconnectionstring();         using (oracleconnection connection = new oracleconnection())         {             connection.connectionstring = connectionstring;             connection.open();             console.writeline("state: {0}", connection.state);             console.writeline("connectionstring: {0}",                               connection.connectionstring);              oraclecommand command = connection.createcommand();               // string sqlquery = "update pohead set byrusr_id = upper(" + (txtbox1.text) + ") byrusr_id = upper(" + (txtbox2.text) + ") , po_st in(1, 4, 5, 6, 10,11)";               string sql = "select * susr usr_id = 'k1342231'";               command.commandtext = sql;              oracledatareader reader = command.executereader();             while (reader.read())             {                 string myfield = (string)reader["myfield"];                 console.writeline(myfield);             }         }     }      private void form1_load(object sender, eventargs e)     {      }      private void runbtn_click(object sender, eventargs e)     {          if (string.isnullorwhitespace(txtbox1.text))         {             messagebox.show("no new user id entered.");         }         if (string.isnullorwhitespace(txtbox2.text))         {             messagebox.show("no old user id entered.");         }         else         {              messagebox.show(connectandquery());        // string sqlquery = "update pohead set byrusr_id = upper('" + (txtbox1.text) + "') byrusr_id = upper('" + (txtbox2.text) + "') , po_st in(1, 4, 5, 6, 10,11)";         //messagebox.show(sqlquery);         }     }      private void resetbtn_click(object sender, eventargs e)     {         txtbox1.clear();         txtbox2.clear();         }      private void closebtn_click(object sender, eventargs e)     {         this.close();     } } } 

obviously want show message using messagebox.show(connectandquery());. show-message expects string s parameter, assign call method returning nothing (void). assume want call connectandquery-method , afterwards show log-message:

connectandquery() messagebox.show("success"); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -