SqlConnection error index 0 in c# -


in code below see error when try connect connection string thiss error appears

format of initialization string not conform specification starting @ index 0.

how can fix it? in code below see error when try connect connection string thiss error appears

format of initialization string not conform specification starting @ index 0.

how can fix it?

namespace insertuserapp {     public partial class home : form     {         class comboitemexample         {             public string displaystring { get; set; }             public string connectionstring { get; set; }              public override string tostring() { return displaystring; }         }         private string connstring = "<default connection>";          public home()         {              initializecomponent();              var srv1 = new comboitemexample { displaystring = "srv1", connectionstring = "data source=tcp:10.0.0.110;initial catalog=database1;user id=user;password=pass;" };             cmbsrv.items.add(srv1);              var srv2 = new comboitemexample { displaystring = "srv2", connectionstring = "data source=tcp:10.1.0.11;initial catalog=database2;user id=user;password=pass;" };             cmbsrv.items.add(srv2);              var srv3 = new comboitemexample { displaystring = "srv3", connectionstring = "data source=tcp:10.1.0.15;initial catalog=database3;user id=user;password=pass" };             cmbsrv.items.add(srv3);          }               private void txtid_textchanged(object sender, eventargs e)     {              using (sqlconnection connection = new sqlconnection(connstring))             {                 /*if (string.isnullorempty(txtid.text))                 {                     messagebox.show("plotesoni fushat unid", "error", messageboxbuttons.ok, messageboxicon.warning);                  }                 else                 {*/                 sqlcommand command1 =                 new sqlcommand("select * table1 tag = 'user' , unid = '" + txtid.text + "'", connection);                 sqlcommand command2 =                 new sqlcommand("select * table1 tag = 'pass' , unid = '" + txtid.text + "'", connection);                 sqlcommand command3 =                 new sqlcommand("select * table1 tag = 'shifra1' , unid = '" + txtid.text + "'", connection);                 sqlcommand command4 =                 sqlcommand command5 =                 new sqlcommand("select * table2 unid = '" + txtid.text + "'", connection);                 connection.open();                  sqldatareader read1 = command1.executereader();                   while (read1.read())                 {                     txtid.text = (read1["unid"].tostring());                     txtuser.text = (read1["value"].tostring());                  }                 read1.close();                 sqldatareader read2 = command2.executereader();                 while (read2.read())                 {                     txtpass.text = (read2["value"].tostring());                 }                 read2.close();                 sqldatareader read3 = command3.executereader();                 while (read3.read())                 {                     txtorg.text = (read3["value"].tostring());                 }                 read3.close();                 sqldatareader read5 = command5.executereader();                 while (read5.read())                 {                     txtgrp.text = (read5["shifra1"].tostring());                 }                 read5.close();             }         }           }     } } 

as reviewed on internet think problem in line of code

any suggestions?

var srv1 = new comboitemexample { displaystring = "srv1", connectionstring = "data source=tcp:10.0.0.110;initial catalog=database1;user id=user;password=pass;" };         cmbsrv.items.add(srv1); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -