Friday, November 3, 2017

DataMethods Plus Webconfig

web config:.

<connectionStrings> 
    <!-- Crm-Dev Tpl Test -->
    <add name="ApplicationServicesTest" connectionString="Data Source=172.16.2.86\SQL14;Initial Catalog=TPL_Test;User Id=crmsupport;Password=swbestteam" providerName="System.Data.SqlClient"/>
    <add name="ApplicationServices" connectionString="Data Source=MNET-PC;Initial Catalog=DbTest;User Id=sa;Password=sa123" providerName="System.Data.SqlClient"/>
  </connectionStrings>

---------------------------------------------------------------------------------------------
--before appsetting


public DataTable GetAllActivity()
        {
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            var sqlad = new SqlDataAdapter("GetAllEmps", con);
            sqlad.SelectCommand.CommandType = CommandType.StoredProcedure;
            var ds = new DataSet();
            con.Open();
            sqlad.Fill(ds);
            con.Close();
            return ds.Tables[0];
        }

        public DataTable GetAllCity()
        {
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            var sqlad = new SqlDataAdapter("GetCity", con);
            sqlad.SelectCommand.CommandType = CommandType.StoredProcedure;
            var ds = new DataSet();
            con.Open();
            sqlad.Fill(ds);
            con.Close();
            return ds.Tables[0];
        }

        public DataTable GetAllCounrty()
        {
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            var sqlad = new SqlDataAdapter("GetCountry", con);
            sqlad.SelectCommand.CommandType = CommandType.StoredProcedure;
            var ds = new DataSet();
            con.Open();
            sqlad.Fill(ds);
            con.Close();
            return ds.Tables[0];
        }

        public DataTable savedata(string cityid, string countryid)
        {
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            var sqlad = new SqlDataAdapter("InsertData", con);
            sqlad.SelectCommand.CommandType = CommandType.StoredProcedure;
            sqlad.SelectCommand.Parameters.AddWithValue("cityid", cityid);
            sqlad.SelectCommand.Parameters.AddWithValue("countryid", countryid);
            var ds = new DataSet();
            con.Open();
            sqlad.Fill(ds);
            con.Close();
            return ds.Tables[0];
        }


        public DataTable GetAllData()
        {
            var con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
            var sqlad = new SqlDataAdapter("GetAlldata", con);
            sqlad.SelectCommand.CommandType = CommandType.StoredProcedure;
            var ds = new DataSet();
            con.Open();
            sqlad.Fill(ds);
            con.Close();
            return ds.Tables[0];
        }
////////////////////////////////////

SQL Procedure 
ALTER Procedure [dbo].[InsertData]
@cityid int,
@countryid varchar(100)

--@cityid int=2,
--@countryid varchar(100)='14,5'
As
Declare @t TABLE
(
EmployeeID INT,
Certs VARCHAR(8000)
)

INSERT @t VALUES (@cityid,@countryid)

SELECT  EmployeeID,
LTRIM(RTRIM(m.n.value('.[1]','varchar(8000)'))) AS Certs
into #temp FROM
(
SELECT EmployeeID,CAST('<XMLRoot><RowData>' + REPLACE(Certs,',','</RowData><RowData>') + '</RowData></XMLRoot>' AS XML) AS x
FROM   @t
)t
CROSS APPLY x.nodes('/XMLRoot/RowData')m(n)


Insert into tb1
select *from #temp

 Select 1 as [Status],'data Has been saved'  as [Message]

Drop Table #temp



Thursday, October 26, 2017

MVC Start Up web Links

http://www.guriddo.net/demo/guriddojs/selection/checkbox/index.html

http://www.c-sharpcorner.com/article/filters-in-Asp-Net-mvc-5-0-part-twelve/

http://www.c-sharpcorner.com/UploadFile/3d39b4/rendering-a-partial-view-and-json-data-using-ajax-in-Asp-Net/
http://www.c-sharpcorner.com/UploadFile/0c1bb2/bind-html-table-using-json-data-in-Asp-Net-mvc/

Login Form in MVC

@model KeDispatcher.Models.Login

//////
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "loginForm" }))
{
    <div class="wrapper">
        <div class="login-area clearfix">
            <div class="company-image"><img src="@Url.Content("~/Content/themes/red/images/login-logo.png")" width="296" height="89" /></div>
            <div class="login-msg">Please enter UserId and Password</div>
            <p></p>
            <div class="login-fields">
                @Html.TextBoxFor(m => m.userid, new { @class = "user-number", autocomplete = "off" })

                <p></p>
                @Html.PasswordFor(m => m.password, new { @class = "user-pin" })
            </div>
            <p></p>
            @*<p><img src="/Authentication/ShowCaptchaImage" /></p>*@
            @*<p>Please enter the string as shown above:</p>
                <p>@Html.TextBox("CaptchaText")</p>*@
            <div class="login-buttons clearfix">
                @*<span class="change-pin">@Html.ActionLink("Change PIN", "Login", "Authentication", new { onclick = "AlertEditNo();" })</span>*@
                <button id="btlogin" class="login-button">Log In</button>
                @ViewBag.result
            </div>
        </div>
        @if (!String.IsNullOrEmpty(@ViewBag.result))
        {
            @:
            <script type="text/javascript">alert('@ViewBag.result')</script>
        }
        @if (!String.IsNullOrEmpty(@ViewBag.result))
        {
            @:
            <script type="text/javascript">alert('@ViewBag.result')</script>
        }
        <!--Footer Start-->
        @*<div class="footer clearfix">
                <div class="footer-text">©2015 TPL Trakker All Right Reserved.</div>
            </div>*@
        <!--Footer End-->
    </div>
}

Sunday, March 29, 2015

ASP .Net WebForms applications /Asp.net MVC

  • The page lifecylce is simpler and more efficient
  • There is no such thing as controls besides html controls. You don't need to debug your output to see ASP .Net is generating.
  • ViewModels give you immense power and obliviate the need to do manual control binding and it eliminates many errors relating to binding.
  • You can have multiple forms on a page. This was a serious limitation on WebForms.
  • The web is stateless and MVC matches the architecture of the web more closely. Webforms introduces state and the bugs you have with it by introducing the Viewstate. The ViewState is automatic and works in the background, so it doesn't always behave the way you want to.
  • Web applications need to work with ajax these days. It's not acceptable to have full page loads anymore. MVC makes ajax so so much better, easier and more efficient with JQuery.
  • Because you can have multiple forms on a page, and because the architecture is driven by calls to urls, you can do funky things like ajax load a different form, like an edit form into your current page using JQuery. Once you realise what this lets you do you can do amazing things easily.
  • ASP .Net WebForms is not only an abstraction over html, it is an extremely complex one. Sometimes you would get a weird bug and struggle with it for much longer than need be. In many cases you could actually see what it was doing wrong but you are unable to do anything about it. You end up doing weird workarounds.
  • WebForms does not make a good technology for designers. Designers often like doing html directly. In MVC its a view, in WebForms its half a day of work.
  • As the web platform is evolving fast WebForms wont keep up. Its not aware of new tags or features of HTML5, it will still render the same stuff unless you get (often) expensive 3rd party controls or wait for Microsoft to issue an update.
  • Controls in WebForms limit you in so many ways. In MVC you can just grab a JQuery library and integrate it into your templates.

Wednesday, January 16, 2013

Mobile captured Video not playing on server


Media Issues And Solutions


Error Description:.

We are enable to connect to the content that you are requested.We are apologise for the inconvenience.


Solution:.

MP4 videos require a MIME type on your server to play properly
If MP4 videos do not display when your Articulate content is hosted on a server, it's likely that the server is not configured to play these files.
Some servers do not have an associated MIME type to support MP4 files. To correct this issue, add an MP4 MIME type to your server. Here's how:
  1. Right-click the site in IIS and select Properties.
  2. Select the HTTP Headers Tab.
  3. Select File Types.
  4. Under the MIME Map section, select New Type.
  5. Type ".mp4" as the associated extension and "video/mpeg" as the content type.
  6. Click OK.
Your MP4 movies should now play when viewed from the server. If you use a hosting company to host your files, it's best to check with them about adding MP4 as a supported MIME type.

Tuesday, January 1, 2013

Asp.net Hidding columns with different Methods

1) Hiding Columns using CSS:


<style type="text/css">
    .hidden
    {
        display: none;
    }
</style>

 
<asp:GridView runat="server" ID="gvHiddenColumnsCSS" AutoGenerateColumns="False"
    Caption="<b>1) using CSS</b>" CellPadding="4" BorderStyle="Solid" ForeColor="#333333"
    GridLines="None" BorderColor="#507CD1">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:BoundField DataField="Id" HeaderText="ID" ItemStyle-CssClass="hidden" 
                        ControlStyle-CssClass="hidden" HeaderStyle-CssClass="hidden" 
                        FooterStyle-CssClass="hidden" />
        <asp:BoundField DataField="Name" HeaderText="Name" />
    </Columns>
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <RowStyle BackColor="#EFF3FB" />
</asp:GridView>
 
Above gridview displays only Name column where as ID column will be hidden. Still, we will be able to retrieve ID value as
string strID= gvHiddenCSS.Rows[row Index].Cells[0].Text;
 2) Hiding Columns using DataKeys:
We can use Datakeys to add one or more columns which are not displayed in the GridView. Following my
previous example, We can add ID as Datakeys and remove the boundfield (ID column) from the GridView.
<asp:GridView runat="server" ID="gvHiddenDataKeys" AutoGenerateColumns="False" CellPadding="4" BorderStyle="Solid" ForeColor="#333333" GridLines="None" BorderColor="#507CD1" Caption="<b>2) using DataKeys</b>" DataKeyNames="ID"> <AlternatingRowStyle BackColor="White" /> <Columns> <asp:BoundField DataField="Name" HeaderText="Name" /> </Columns> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#EFF3FB" /> </asp:GridView>
 
We can retrieve ID value as


string strID=gvHiddenDataKeys.DataKeys[row index].Value.ToString();


3) Hiding Columns using Visible Property
 
<asp:GridView runat="server" Caption="<b>3) using Visible Property</b>" ID="gvHiddenVisible"
    AutoGenerateColumns="False" CellPadding="4" BorderStyle="Solid" ForeColor="#333333"                                                                                              
    GridLines="None" BorderColor="#507CD1" OnDataBinding="gvHiddenVisible_DataBinding"
    OnDataBound="gvHiddenVisible_DataBound">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:BoundField DataField="ID" HeaderText="ID" />
        <asp:BoundField DataField="Name" HeaderText="Name" />
    </Columns>
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <RowStyle BackColor="#EFF3FB" />
</asp:GridView>
protected void gvHiddenVisible_DataBinding(object sender, EventArgs e)
{
    gvHiddenVisible.Columns[0].Visible = true;
}
protected void gvHiddenVisible_DataBound(object sender, EventArgs e)
{
    gvHiddenVisible.Columns[0].Visible = false;
}

 
 




only Name column where as ID column will be hidden. Still, we will be able to retrieve ID value as

string strID= gvHiddenCSS.Rows[row Index].Cells[0].Text;

 

Saturday, October 20, 2012

Restored Database/Diagrams Support/SQL-Server 2005


After restoring DB in SQL Server 2005 db most of the time I get the following error:

Database diagram support objects cannot be installed because this database does not have a valid owner. To continue, first use the Files page of the Database Properties dialog box or the ALTER AUTHORIZATION statement to set the database owner to a valid login, then add the database diagram support objects.

Solution

1. Right Click on your database, choose properties
2. Goto the Options Page
3. In the Dropdown at right labeled "Compatibility Level" choose "SQL Server 2005(90)"
4. Goto the Files Page
5. Enter "sa" in the owner textbox.
6. Hit OK

This Work for me but not work move further!!

But for some reason these steps did not work.... After googling for a while I quickly found
the following suggestion which worked just fine for me....

EXEC sp_dbcmptlevel 'yourDB', '90';
go
ALTER AUTHORIZATION ON DATABASE::yourDB TO "yourLogin"
go
use [yourDB]
go
EXECUTE AS USER = N'dbo' REVERT
go