Search This Blog

Tuesday, 27 August 2013

An existing connection was forcibly closed by the remote host - WCF

When WCF connection closed forcefully we need to increase the data size length and other respective properties


An existing connection was forcibly closed by the remote host - WCF

An existing connection was forcibly closed by the remote host - WCF

<bindings>
      <wsHttpBinding>
        <binding name="BindingWCFService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="900000" maxStringContentLength="104857600" maxArrayLength="104857600" maxBytesPerRead="104857600" maxNameTableCharCount="104857600" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="DefaultServiceBehavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpsGetEnabled="true" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
          <serviceThrottling maxConcurrentCalls="2147483647" maxConcurrentSessions="2147483647" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="EndPointBehaviorWCFService">
          <clientCredentials>
            <windows allowNtlm="true" allowedImpersonationLevel="Impersonation" />
          </clientCredentials>
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>

Wednesday, 22 May 2013

Pass table values from Application to Data base in c# and sql server 2008


List<SqlDataRecord> sqlDataRecordListGISOfficers = new List<SqlDataRecord>();
                        SqlMetaData[] sqlMetaDataGISOfficers ={
                                                                new SqlMetaData("ColumnName", SqlDbType.NVarChar,100 ),
                                                                  new SqlMetaData("ColumnName",SqlDbType.Int),
                                                                  new SqlMetaData("ColumnName",SqlDbType.NVarChar,100),
                                                                  new SqlMetaData("ColumnName",SqlDbType.Int),
                                                                  new SqlMetaData ("ColumnName",SqlDbType.Bit),
                                                                  new SqlMetaData("ColumnName",SqlDbType.NVarChar,100),
                                                                  new SqlMetaData("ColumnName",SqlDbType.NVarChar,100)

                                                             };

                        if (application.ApplAssignedOfficers != null)
                        {
                            foreach (ApplAssignedOfficers AppOfficer in application.ApplAssignedOfficers)
                            {
                                SqlDataRecord sqlDataRecordApp = new SqlDataRecord(sqlMetaDataGISOfficers);
                                sqlDataRecordApp.SetSqlString(0, AppOfficer.ListName);
                                sqlDataRecordApp.SetInt32(1, AppOfficer.ListName);
                                sqlDataRecordApp.SetSqlString(2, AppOfficer.ListName);
                                sqlDataRecordApp.SetInt32(3, AppOfficer.ListName);
                                sqlDataRecordApp.SetBoolean(4, AppOfficer.ListName);
                                sqlDataRecordApp.SetSqlString(5, AppOfficer.ListName);
                                if (!string.IsNullOrEmpty(AppOfficer.ListName))
                                {                                  
                                    sqlDataRecordApp.SetSqlString(6, AppOfficer.ListName);
                                }
                                sqlDataRecordListGISOfficers.Add(sqlDataRecordApp);
                            }
                        }


    SqlParameter tvpParam = new SqlParameter();
                        if (sqlDataRecordListGISOfficers.Count > 0)
                        {
                            tvpParam.ParameterName = "@ParameterName";
                            tvpParam.SqlDbType = SqlDbType.Structured;
                            tvpParam.TypeName = "TableTypeName";
                            tvpParam.Value = sqlDataRecordListGISOfficers;//List Name
                            cmd.Parameters.Add(tvpParam);
                        }

Need to MERGE statement at database side