How to parse IP address from IP address Control [Custom toolbox item] and store it to MySQL DB in Visual C# -


how store ip addresses ip address control textbox

[it custom visual studio toolbox item here: github: ipaddresscontrol ] not able explain better documentation available on link.

( gist of toolbox item allows input ips in same way set ip addresses in ethernet/wifi adapters: has 4 specialized textbox controls of type field controls , separated 3 dot controls. again urge go github link. may useful in future)

it user-friendly way of storing ip addresses.

how should parse ips custom toolbox , store them mysql db?

i new this...please tell me if want further info.

screenshot

thank you.

based on documentation, values custom ip textbox control this:

byte[] ipaddressbytes = ipaddresscontrol.getaddressbytes(); 

then want setup connection sql database (i not expand on that, since isn't problem. can read here.

when have connection db established , have appropriate table storing ip's in database (i'd suggest string) can first change bytes array string ip address so:

string[] ipaddressstrbytes = new string[4]; (int = 0; < 4; i++) {     ipaddressstrbytes[i] = ipaddressbytes[i].tostring(); } string ipaddress = string.join(".", ipaddressstrbytes) 

and build sql query so:

using (sqlcommand command = new sqlcommand("insert tablename values(@ip)", connection)) { command.parameters.add(new sqlparameter("ip", ipaddress));  command.executenonquery(); } 

edit 2:

i hesitant try (documentation states it's vs2010 i'm pretty sure work in later versions , simplify code lot)

string ipaddress = ipaddresscontrol.ipaddress.tostring(); 

that should give string in format "x.x.x.x" can push sql query showed above.