asp.net - add sub into vb.net happen connection strings property has not been initialized -
i have found lot of solution regarding connection strings property has not been initialized, have try follow , checking solution still not able fix problems.
it happen while add private sub getdetails(), if remove sub recover. not happen other private sub this.
private sub getorglocedit() dim strsql string dim params new hashtable dim dt new datatable try params.clear() strsql = "select c.mmc_states + ' - ' + c.mmc_desti desti [database].[dbo].[tbods] o " & _ " inner join [database].[dbo].tbodsmealmilageclaims c " & _ " on o.ods_destination = c.mmc_states + ' - ' + c.mmc_desti " & _ " c.mmc_company = @company , o.ods_id = @id order c.mmc_states, c.mmc_desti " params.add("@company", ddlcompany.selectedvalue.trim) params.add("@id", txtid.text.trim) if dt.rows.count > 0 ddlorgloc.datasource = dt ddlorgloc.datatextfield = "desti" ddlorgloc.datavaluefield = "desti" ddlorgloc.databind() else ddlorgloc.items.clear() end if common.execreadergreen(strsql, params, dt, common.txn) catch ex exception throw ex end try end sub connection string:
<add name="connstringgreen" connectionstring="data source=servername;database=database;persist security info=true; user id=user;password=password" providername="system.data.sqlclient" /> openconn method:
public sub openconn() try 'portal connection=========== conn.connectionstring = configurationmanager.connectionstrings("connstringgreen").connectionstring if not conn nothing if conn.state = data.connectionstate.closed conn.open() end if else throw new exception("can't connect portal sql server!") end if
do this:
conn.connectionstring = configurationmanager.connectionstrings("connstringgreen")
Comments
Post a Comment