select * from (
select ROW_NUMBER() OVER (ORDER BY TableID) ROWNUMBER ,* from [Your Table]) t2
where t2.ROWNUMBER =شماره سطر
ASP.Net C# SQL Server خاطره عکس موسیقی گیتار دلنوشته برنامه نویسی...
select * from (
select ROW_NUMBER() OVER (ORDER BY TableID) ROWNUMBER ,* from [Your Table]) t2
where t2.ROWNUMBER =شماره سطر
Int32 myVar = null; //error: myVar cannot be set to null
این خطا به این دلیله که در حالت عادی این گونه متغیرها نمیتونن مقادریر Null بپذیرن. برای حل این مشکل میتونیم از System.Nullable استفاده کنیم که علاوه بر مقدیر مناسب Datatype میشه Null رو هم بهش نسبت داد.Nullable<T> myVar = null;
T? myVar = null;
Nullable<Int32> myVar = null;
Int32? myVar = null;
// ?? operator example.
int? x = null;
// y = x, unless x is null, in which case y = -1.
int y = x ?? -1;
System.Nullable<int> i1 = 0;
System.Nullable<int> i2 = null;
int i3 = 0;
if (i1 == i2)
}
i1 and i2 are different
i1 and i3 are the same
System.Nullable<int> i1 = null;
try
{
System.Console.WriteLine("The value is {0}", i1.Value);
}
catch
{
System.Console.WriteLine("null causes an exception");
}
i1 = 1;
try
{
System.Console.WriteLine("The value is {0}", i1.Value);
}
catch
{
System.Console.WriteLine("1 causes an exception");
}
null causes an exception
The value is 1
int DefaultIfNull(System.Nullable<int> i)
{
int retVal;
if (i.HasValue)
{
retVal = i;
}
else
{
retVal = 1;
}
return retVal;
}
int DefaultIfNull(System.Nullable<int> i)
{
return i ?? 10;
}
private void button1_Click(object sender, EventArgs e)
{
bool b=true;
b = nima(null);
MessageBox.Show(b.ToString());
b = nima(2);
MessageBox.Show(b.ToString());
}
private bool nima(int? i)
{
if (i == null)
return false;
else
return true;
}
[RunInstaller(true)]
public partial class Installer1 : Installer
{
string path;
public Installer1()
{
InitializeComponent();
}
private void AttachDB()
{
try
{
SqlConnection cn = new SqlConnection("Data Source=.;Initial Catalog=InstallDB;Integrated Security=True");
Assembly asm = Assembly.GetExecutingAssembly();
path = System.IO.Path.GetDirectoryName(asm.GetName().CodeBase);
path = path.Substring(6) + "\\DB\\";
Server SqlServer = new Server();
//System.Windows.Forms.MessageBox.Show(path);
string DatabaseName = "InstallDB";
ServerConnection SqlServerConnection = SqlServer.ConnectionContext;
if (SqlServer.Databases[DatabaseName] == null)
{
Database NewDatabase = new Database(SqlServer, DatabaseName);
FileGroup DatabaseFileGroup = new FileGroup(NewDatabase, "PRIMARY");
NewDatabase.FileGroups.Add(DatabaseFileGroup);
DataFile DatabaseDataFile = new DataFile(DatabaseFileGroup, DatabaseName);
DatabaseFileGroup.Files.Add(DatabaseDataFile);
DatabaseDataFile.FileName = path + "InstallDB.mdf";
LogFile DatabaseLogFile = new LogFile(NewDatabase, DatabaseName + "_log");
NewDatabase.LogFiles.Add(DatabaseLogFile);
DatabaseLogFile.FileName = path + "InstallDB_log.ldf";
NewDatabase.Create(true);
}
else
System.Windows.Forms.MessageBox.Show("این دیتابیس وجود دارد");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.InnerException.InnerException.ToString());
}
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
//System.IO.File.Create(@"c:\t.txt");
AttachDB();
}
public override void Uninstall(System.Collections.IDictionary savedState)
{
base.Uninstall(savedState);
Server SqlServer = new Server();
string DatabaseName = "InstallDB";
if (SqlServer.Databases[DatabaseName] != null)
{
SqlServer.DetachDatabase(DatabaseName, true);
}
//Assembly asm = Assembly.GetExecutingAssembly();
//path = System.IO.Path.GetDirectoryName(asm.GetName().CodeBase);
//path = path.Substring(6) + "\\DB\\";
//System.IO.File.Delete(path + DatabaseName + ".mdf");
//System.IO.File.Delete(path + DatabaseName + "_log.ldf");
}
}
یه پروژه جدید از نوع Setup Project به سولوشن اضافه کنین .من داخل ویوی File System یک پوشه به اسم DB قرار ایجاد کردم فایلهای دیتابیس (mdf و ldf ) رو به داخل اون منتقل کرد خاصیت AlwaysCreate رو به true و DeafultLocation رو به [TARGETDIR]\DB تغییر دادم. بعد از تنظیمات مربوطه که پروژه قبلی رو ست آپ کنه به ویوی Custom Action برین و برای رویدادهای Commit و UnInstall رو (همونطوری که نمونش در فیلم آموزش خانم بیتا هست) به پروژه ای که کلاس Installer داره نسبت بدین تا در موقع اتفاق افتادن ایونتهای مورد نظر کده مورد نظر اجرا بشه . من یه تیکه کد کامنت شده نوشتم که دیتابیس رو بعد از UnInstall پاک میکنه شما هر کاری دوست دارین میتونین بکنین اعم از اینکه به پوشه ای دیگه ای منتقلشون کنین امیوارم که مفید باشه.
daUpdateCommand.Parameters.Add(new SqlParameter("@pTimeStamp", SqlDbType.Binary));
daUpdateCommand.Parameters["@pTimeStamp"].SourceVersion = DataRowVersion.Original;
daUpdateCommand.Parameters["@pTimeStamp"].SourceColumn = "TimeStampCol";
SourceVersion: در SqlDataAdapter.UpdateCommand استفاده میشود و مشخص میکند طی بروز رسانی از مقدار فعلی پارامتر استفاده شود یا از مقدار اصلی و اولیه.
DataRowVersion: نسخه DataRow را مشخص میکند. DataRowVersion یک مجموعه است که 4 مقدار Original ، Current ، Proposed و Default را در خود دارد. در کد بالا به دلیل اینکه میخواهیم از مقدار اصلی موجود در جدول استفاده کنیم از Original استفاده میکنیم
SourceColumn : هم ستونی را که باید این پارامتر از آن مقدار بگیرد را مشخص میکند.
class HDITextBox : System.Windows.Forms.TextBox
بسیار خوب حالا برای اینکه ممکنه این عدد 70 و 85 تغییر کنه دو تا خصوصیت برای کلاسمون در نظر میگیریم:
private double _WarnLevelMaxing =.85;
public double WarnLevelMaxing
{
get { return _WarnLevelMaxing; }
set
{
_WarnLevelMaxing = value;
}
}
private double _WarnLevelRisky=.70;
public double WarnLevelRisky
{
get { return _WarnLevelRisky; }
set
{
_WarnLevelRisky = value;
}
}
تنها کاری که مونده اینه که متد OnTextChanged رو override کنیم تا کاری که ما میخوایم رو انجام بده:
protected override void OnTextChanged(System.EventArgs e)
{
if (this.MaxLength > 0)
{
double currentLevel = Convert.ToDouble( this.Text.Trim().Length) / Convert.ToDouble(this.MaxLength);
if (currentLevel > _WarnLevelMaxing)
{
this.ForeColor = System.Drawing.Color.Red;
return;
}
if (currentLevel > _WarnLevelRisky)
{
this.ForeColor = System.Drawing.Color.Plum;
return;
}
if (currentLevel <= _WarnLevelRisky)
{
this.ForeColor = System.Drawing.Color.Black;
return;
}
}
base.OnTextChanged(e);
}



public delegate void MyDelegate(string myString);
1 private void MyMethod(string someString)
2 {
3 // method body here.
4 }
private string MyOtherMethod(string someString)
{
// method body here.
}
private void YetAnotherMethod(string someString, int someInt)
{
// method body here.
}
MyDelegate del = new MyDelegate(MyMethod);
del += new MyDelegate(MyOtherMethod);
del("my string value");
. رفتم آکوردشو پیدا کردم ولی خوب چشمتون روزه بد نبینه فکر کنم عمرا نمیشه این آهنگ رو با این آکوردهایی که نوشته با گیتار زد.تو یه کلمه باید سه بار آکورد عوض کرد
.static readonly Regex socialSecurityNumberCheck = new Regex(@"^\d{3}-?\d{2}-?\d{4}$");
static readonly Regex socialSecurityNumberCheck = new Regex(Pattern.With.AtBeginning
.Digit.Repeat.Exactly(3)
.Literal("-").Repeat.Optional
.Digit.Repeat.Exactly(2)
.Literal("-").Repeat.Optional
.Digit.Repeat.Exactly(4)
.AtEnd);

10 using System.Text.RegularExpressions;
11 ...
12 const string ALL_NUMERIC_PATTERN = "[a-zA-Z]";
13 static readonly Regex All_Numeric_Regex =
14 new Regex (ALL_NUMERIC_PATTERN);
15 static bool AllNumeric ( string inputString )
16 {
17 if (All_Numeric_Regex.IsMatch ( inputString ))
18 {
19 return false;
20 }
21 return true;
استفاده از یک HTTP Handler برای ترکیب فایلهای جاوا اسکریپتی و CSS :
(دوستان عزیز نوشتن تو این ادیتور واقعا به درد نخوره خیلی اذیت میکنه مقاله ها رو با فرمت doc یا pdf میذارم که راحت باشین)