我正在使用SqlBulkCopy类在表中一次插入50k行tbl_records
我After Insert在此表上设置了一个触发器并使用以下代码
SqlBulkCopy SqlBc1 = new SqlBulkCopy(strConnString, SqlBulkCopyOptions.FireTriggers);
// Set DataReader For SqlBulkCopy
sqlComm = new SqlCommand(strQuery, sqlTemCon);
sqlComm.CommandTimeout = 3600000;
sqlComm.CommandType = System.Data.CommandType.Text;
SqlDataReader dReader = sqlComm.ExecuteReader();
SqlBc1.WriteToServer(dReader);
Run Code Online (Sandbox Code Playgroud)
但执行前后.它只触发First 50k插入的行
我想它应该为每一行开火.我怎样才能做到这一点??
我刚刚编写代码并发现一些奇怪的事情.如果我尝试Transaction像这样制作类的实例
Transaction ts = new Transaction();
Run Code Online (Sandbox Code Playgroud)
编译器引起我的错误 The type System.Transactions.Transaction has no constructor defined
当我浏览这个类的定义时,我发现它被定义为public,没有Static或者是Abstract关键字.
namespace System.Transactions
{
// Summary:
// Represents a transaction.
[Serializable]
public class Transaction : IDisposable, ISerializable
{
// Summary:
// Returns a value that indicates whether two System.Transactions.Transaction
// instances are not equal.
//
// Parameters:
// x:
// The System.Transactions.Transaction instance that is to the left of the inequality
// operator.
//
// y:
// The System.Transactions.Transaction instance …Run Code Online (Sandbox Code Playgroud) 我正在使用DateTime.TryParseExact函数使用以下代码获取变量中的datetime值
DateTime dt;
CultureInfo provider = CultureInfo.InvariantCulture;
System.Globalization.DateTimeStyles style = DateTimeStyles.None;
string[] format = new string[] { "d/MMM/yy H:m:s tt","d-MMM-yy H:m:s tt" };
string strDate = "24-May-13 12:03:03 AM";
DateTime.TryParseExact(strDate, format, provider, style, out dt);
Run Code Online (Sandbox Code Playgroud)
现在它做了什么它正确解析日期时间并给我结果24-May-2013 12:03:03
但我希望它应该像这样返回我24-May-2013 00:03:033
我怎样才能做到这一点 ?
我是 MVC 的新手,正在尝试完善webgrid. 我有以下代码view
@model IEnumerable<MVCMovies.Models.Movie>
@{
ViewBag.Title = "Index";
}
<script type="text/javascript">
$(function() {
$('tbody tr').on('hover', (function () {
$(this).toggleClass('clickable');
}));
$('tbody tr').on('click', (function () {
alert('rajeev');
}));
});
</script>
<style type="text/css">
.table {
margin: 4px;
width: 100%;
background-color: #FCFCFC;
}
.head {
background-color: #11E8CD;
font-weight: bold;
color: #CC6699;
}
.webGrid th, .webGrid td {
border: 1px solid #C0C0C0;
padding: 5px;
color:white;
}
.altRow {
background-color: #E4E9F5;
color: #000;
}
.gridHead a:hover {
text-decoration: underline;
} …Run Code Online (Sandbox Code Playgroud) 我写HV以下功能having two database context于一体transaction scope。我使用MySql与EF 5.0
private static void SyncPremiumStores(JoyRydeWebPortalData.joyryde_WebPortalEntities contextWebPortal, JoyRydeMallStoreData.joyryde_MallStoreEntities contextMallStore)
{
using (TransactionScope scope = new TransactionScope())
{
foreach (var objWebPortalPremiumStore in contextWebPortal.tbl_premium_store.Where(x => x.INT_DATA_TRANS_STATUS == 0).ToList())
{
try
{
var objMallStore = contextMallStore.tbl_store.Where(x => x.LNG_STORE_ID == objWebPortalPremiumStore.LNG_STORE_ID).FirstOrDefault();
if (objMallStore != null)
{
JoyRydeMallStoreData.tbl_premium_store objMallPremiumStore = new JoyRydeMallStoreData.tbl_premium_store()
{
DAT_CREATED = objWebPortalPremiumStore.DAT_CREATED,
DAT_PREMIUM_FROM = objWebPortalPremiumStore.DAT_PREMIUM_FROM,
DAT_PREMIUM_TO = objWebPortalPremiumStore.DAT_PREMIUM_TO,
LNG_PRIMARY_STORE_ID = objMallStore.LNG_PRIMARY_STORE_ID,
LNG_STORE_ID = objMallStore.LNG_STORE_ID,
TXT_PACK_NAME = ""
};
contextMallStore.tbl_premium_store.Add(objMallPremiumStore);
objWebPortalPremiumStore.INT_DATA_TRANS_STATUS …Run Code Online (Sandbox Code Playgroud) 我一直在使用Action_View,以install apk使用下面的代码
Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
intent.setDataAndType(Uri.fromFile(new File(location + "myAPK.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
它会在设备中打开“安装提示”窗口。现在用户可以安装或取消安装过程。
我只对当用户单击安装包但由于某种原因安装失败可能是损坏的 apk 或不匹配的签名 apk 等时感兴趣。
安装失败时如何捕获事件.. 我可以从 ACTION_INSTALL_PACKAGE
我已经阅读过,System Broadcast Messages但所有内容都用于添加或替换 Pacakge。
任何线索?
我正在读取 xls 文件并在 gridview 中显示它。我正在使用以下代码
string strSelectQuery = "Select * from [sheet1$]";
System.Data.OleDb.OleDbCommand= new System.Data.OleDb.OleDbCommand(strSelectQuery, mCon);
DataAdapter = new System.Data.OleDb.OleDbDataAdapter(strSelectQuery, mCon);
DataAdapter.Fill(mDTable);
Run Code Online (Sandbox Code Playgroud)
现在当我去检查以下代码时会发生什么
string strFirstCell = mDTable.Rows[0][0];
Run Code Online (Sandbox Code Playgroud)
它给了我第二行第一个单元格的结果。我想阅读完整的 xls,数据表中没有任何标题行。我希望第一行被指定为数据表中的列名。
我在appconfig文件中有一个appsetting部分
<appSettings>
<add key="DayTime" value="08-20"/>
<add key="NightTime" value="20-08"/>
</appSettings>
Run Code Online (Sandbox Code Playgroud)
我正忙着在应用程序运行时修改app配置.DayTime应用程序运行时,我将密钥更改为11-20.
现在,如果我再次运行此代码以从config获取数据,它将显示先前的设置值.
private void btnDayNightSettings_ShowingEditor(object sender, ItemCancelEventArgs e)
{
string[] strDayTime = ConfigurationManager.AppSettings["DayTime"].Split('-');
}
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
我有一个ShowPanel(Control ctrl)需要Control作为参数传递的函数。我需要在后台工作线程中调用这个函数。我使用以下代码
void bw_DoWork(object sender,DoWorkEventArgs e)
{
ShowPanel(listBox1);
}
Run Code Online (Sandbox Code Playgroud)
但因执行而失败
跨线程操作无效:从创建它的线程以外的线程访问控件“Form1”
我怎样才能listBox1在后台线程中通过这里?
我一直在结合WPF ListBox中Dispatcher使用下面的代码
Dispatcher.BeginInvoke(new Action(() =>
{
LoadData();
}));
private void LoadData()
{
// Written some logic here
}
Run Code Online (Sandbox Code Playgroud)
它绑定ListBox井,但当我打电话
ListBoxItem myListBoxItem = (ListBoxItem)(routeList.ItemContainerGenerator.ContainerFromItem(item));
Run Code Online (Sandbox Code Playgroud)
它总是让我回归.null问题只发生在我绑定ListBox内部时 Dispatcher.如果我ListBox在类构造函数中绑定相同的,它可以正常工作.
c# ×8
winforms ×4
actionview ×1
android ×1
app-config ×1
asp.net-mvc ×1
constructor ×1
datatable ×1
datetime ×1
excel ×1
java ×1
jquery ×1
listbox ×1
mysql ×1
oop ×1
sql-server ×1
sqlbulkcopy ×1
triggers ×1
webgrid ×1
wpf ×1