Disable all the constraint in database
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
Enable all the constraint in database
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
Programming is fun and interesting. As you all know, sometime we programmers stucks in the middle way of coding without getting a solution. Blogs like this will help us to find a path to solve our problems. The contents of this blog are the solutions that I found by myself and from other sources. Sharing such solutions is also interesting. Thank you!
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
onkeypress="return WebForm_FireDefaultButton(event, '<%=ButtonName.ClientID %>')"
<div style="float: left" onkeypress="return WebForm_FireDefaultButton(event, '<%=btnCheckPin.ClientID %>')">
<asp:TextBox ID="txtPincode" runat="server" Style="padding: 5px;"></asp:TextBox>
<input type="button" class="common_button" onclick="checkDelivery();" value="Check" ID="btnCheckPin" runat="server" />
</div>
ALTER TABLE {TABLENAME}
ADD {COLUMNNAME} {TYPE} {NULL|NOT NULL}
CONSTRAINT {CONSTRAINT_NAME} DEFAULT {DEFAULT_VALUE}
[WITH VALUES]
ALTER TABLE table
ADD column BIT
CONSTRAINT Constraint_name DEFAULT 0 WITH VALUES
WITH VALUES
handles the NOT NULL
part... private string ConvertTo24HourFormat(string strTime) //HH:MM AM/PM
{
string FinalTime=string.Empty;
if (!string.IsNullOrEmpty(strTime))
{
try
{
string[] InTime = strTime.Split(':');
int h = Convert.ToInt32(InTime[0].ToString());
string[] AMPM = InTime[1].Split(' ');
if (AMPM[1].ToString() == "PM")
{
h += 12;
}
if (AMPM[1].ToString() == "AM" && h.ToString()=="12")
{
h = 00;
}
FinalTime = h + ":" + InTime[1];
//if(h>
}
catch (Exception) { }
}
return FinalTime;
}
private string ConvertTo12HourFormat(string strTime) //HH:MM AM/PM
{
string FinalTime = string.Empty;
if (!string.IsNullOrEmpty(strTime))
{
try
{
string[] InTime = strTime.Split(':');
int h = Convert.ToInt32(InTime[0].ToString());
string[] AMPM = InTime[1].Split(' ');
if (AMPM[1].ToString() == "PM")
{
h -= 12;
}
if (AMPM[1].ToString() == "AM" && h.ToString() == "00")
{
h = 12;
}
FinalTime = h + ":" + InTime[1];
//if(h>
}
catch (Exception) { }
}
return FinalTime;
}