สอบถามการเปิด Form ค้างไว้ตลอดโดยไม่หาย VB เปิดโปรแกรมอื่่นก็แสดงอยู่ไม่ Hrde ไว้ด้านหลัง
Tag : .NET, VB.NET
Date :
2018-06-28 16:40:52
By :
nutpopo
View :
1080
Reply :
5
No. 1
Guest
Code (VB.NET)
Dim food = New With {
.ID = 1,
.Name = "Carrot",
.Type = (
Function(name As String)
If String.IsNullOrEmpty(name) Then Return String.Empty
Select Case name.ToLower()
Case "apple", "tomato": Return "Fruit"
Case "potato": Return "Vegetable"
End Select
Return "Meat"
End Function
)(.Name)
}
Dim type = food.Type
public static DbDataAdapter CreateDataAdapter(string strSQL, DbConnection cn)
{
DbDataAdapter da = null;
if (cn is SqlConnection){
da = new SqlDataAdapter(strSQL, (SqlConnection)cn);
} else if (cn is OleDbConnection) {
da = new OleDbDataAdapter(strSQL, (OleDbConnection)cn);
} else if (cn is FbConnection) {
da = new FbDataAdapter(strSQL, (FbConnection)cn);
}
else
{
throw new Exception("[CreateDataAdapter] Unknown DbConnection type: " + cn.GetType().FullName);
}
//To use the full power of C# 7 out of box
//(without referencing nugets and so on) you need VS 2017 and .Net 4.7 as Target Framework.
//switch ((true))
//{
// case object cn when cn is SqlConnection:
// {
// da = new SqlDataAdapter(strSQL, cn);
// break;
// }
// case object _ when cn is OleDbConnection:
// {
// da = new OleDbDataAdapter(strSQL, cn);
// break;
// }
// case object _ when cn is FbConnection:
// {
// da = new FbDataAdapter(strSQL, cn);
// break;
// }
// default:
// {
// // TODO: Add more DbConnection kinds as they become invented
// throw new Exception("[CreateDataAdapter] Unknown DbConnection type: " + cn.GetType().FullName);
// break;
// }
//}
return da;
}