my code is like the follow:
SqliteConnection db = new SqliteConnection("uri=file:zongheng.db");db.Open();
SqliteCommand cmd = db.CreateCommand();
cmd.CommandText = "update chapters set status = 0 where bookid=" + bookid + " and chapterid = " + reading_chapter + ";";
cmd.ExecuteNonQuery();
cmd.Dispose();
db.Close();
db.Dispose();
db.Open();
cmd = db.CreateCommand();
cmd.CommandText = ("select max(chapterid), status from chapters where status > 0 and bookid = "+bookid +";");
SqliteDataReader dr = cmd.ExecuteReader(); //exception thrown from here
calling stack is like this:
Community.CsharpSqlite.SQLiteClient.SqliteSyntaxException was unhandled
Message=unable to open database file
StackTrace:
at Community.CsharpSqlite.SQLiteClient.SqliteCommand.GetNextStatement(String pzStart, String& pzTail, Vdbe& pStmt)
at Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior, Boolean want_results, Int32& rows_affected)
at Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteReader()
at ZonghengReader.Content.OnNavigatedTo(NavigationEventArgs e)
at Microsoft.Phone.Controls.PhoneApplicationPage.InternalOnNavigatedTo(NavigationEventArgs e)
at System.Windows.Navigation.NavigationService.RaiseNavigated(Object content, Uri uri, NavigationMode mode, Boolean isNavigationInitiator, PhoneApplicationPage existingContentPage, PhoneApplicationPage newContentPage)
at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content, NavigationMode mode)
at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result)
at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at System.Delegate.DynamicInvokeOne(Object[] args)
at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
at System.Delegate.DynamicInvoke(Object[] args)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)
how can i do different queries within the same connection? any advice? or any documentation? any advice would be highly appreciated.
I don't know if this question is answered yet but... in your code sample you dispose of the object:
...
db.Dispose();
db.Open();
...
I honestly think that's your problem in the current context. just remove the Dispose() call on the database connection object and I think you should be fine. Once you are really done with the object you can Dispose() it.
Related
I recently switched a DotNetNuke 6 install to a .net 4 framework, and i've started getting the following error:
DotNetNuke.Services.Exceptions.PageLoadException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not find file 'Telerik.Web.UI.resources'.
at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at Telerik.Web.LocalizationProvider.EmbeddedResourceLocator.GetString(String resourceKey)
at Telerik.Web.LocalizationStrings.GetString(String key, Boolean throwErrorIfMissing)
at Telerik.Web.LocalizationStrings.GetString(String key)
at Telerik.Web.UI.ComboBoxStrings.get_AllItemsCheckedString() --- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.SecurityUtils.MethodInfoInvoke(MethodInfo method, Object target, Object[] args)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
at System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object o, StringBuilder sb, Int32 depth, Hashtable objectsInUse, SerializationFormat serializationFormat, MemberInfo currentMember)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)
at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, SerializationFormat serializationFormat)
at Telerik.Web.UI.RadComboBox.DescribeComponent(IScriptDescriptor descriptor)
at Telerik.Web.UI.RadDataBoundControl.Telerik.Web.IControl.DescribeComponent(IScriptDescriptor descriptor)
at Telerik.Web.UI.ScriptRegistrar.GetScriptDescriptors(Control control)
at Telerik.Web.UI.RadDataBoundControl.GetScriptDescriptors()
at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IScriptControl.GetScriptDescriptors()
at System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl)
at Telerik.Web.UI.RadDataBoundControl.RegisterScriptDescriptors()
at Telerik.Web.UI.RadDataBoundControl.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl <....snip, rendering call stack>
I have no idea why this error happens since i can't reproduce it on another server, or even on the same server. Since i don't find a solution i'm trying to patch it so i looked at the workaround proposed in this post:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/32e458a1-7443-4309-a054-8839b33dfd4f/framework-40-dll-loaded-by-a-20-executable-cannot-find-xxxxresourcesdll
So the workaround would be to
catch the FileNotFoundException in HostRuntime.ResolveAssembly and return null. This should prevent the process from crashing.
I can add some code to the application through a HttpModule, but i really don't see how i'm supposed to patch the HostRuntime.ResolveAssembly... any idea?
Edit: I've been diggin in the mscorlib assembly for the framework 4 and i see something very weird:
The call from the ManifestBasedResourceGroveler to the SatelliteAssembly loading is the following:
try
{
runtimeAssembly = this._mediator.MainAssembly.InternalGetSatelliteAssembly(satelliteAssemblyName, lookForCulture, this._mediator.SatelliteContractVersion, false, ref stackMark);
}
catch (FileLoadException ex)
{
int hResult = ex._HResult;
Win32Native.MakeHRFromErrorCode(5);
}
catch (BadImageFormatException)
{
}
So it catches exceptions, but here is the code for InternalGetSatelliteAssembly
if (runtimeAssembly == this)
{
throw new FileNotFoundException(string.Format(culture, Environment.GetResourceString("IO.FileNotFound_FileName"), new object[]
{
assemblyName.Name
}));
}
Ok, so i will always get a FileNotFoundException that won't be caught... that looks like a really weird behavior to me
Based on the stack trace it looks like a Telerik version issue. Are you sure that the proper assemblies are all loaded?
When I run the following code :
var db = Database.Open();
var contact = new Contact() {FirstName = "Mark", LastName = "Rendle"} ;
db.Contacts.Insert(contact);
I get an error :
List initializers must contain at least one initializer
Stack Trace :
at System.Linq.Expressions.Expression.ListInit(NewExpression newExpression, IEnumerable1 initializers)
at Simple.Data.Extensions.ObjectEx.MakeToDictionaryFunc(Type type)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Simple.Data.Extensions.ObjectEx.ObjectToDictionary(Object obj)
at Simple.Data.Commands.InsertCommand.InsertEntity(Object entity, DataStrategy dataStrategy, String tableName, ErrorCallback onError, Boolean resultRequired)
at Simple.Data.Commands.InsertCommand.DoInsert(InvokeMemberBinder binder, Object[] args, DataStrategy dataStrategy, String tableName)
at Simple.Data.Commands.InsertCommand.Execute(DataStrategy dataStrategy, DynamicTable table, InvokeMemberBinder binder, Object[] args)
at Simple.Data.DynamicTable.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
at Simple.Data.ObjectReference.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
at CallSite.Target(Closure , CallSite , Object , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
at ProjectXBaseDataImporter.DataSaver.PersistContacts(IEnumerable1 contactsx) in c:\Code\XXX\ProjectXBaseDataImporter\ProjectXBaseDataImporter\CSVImporter.cs:line 54
at ProjectXBaseDataImporter.DataImporter.Import[T](String filePath) in c:\Code\XXX\ProjectXBaseDataImporter\ProjectXBaseDataImporter\CSVImporter.cs:line 77
at ProjectXBaseDataImporter.DataImporter_Test.Import() in c:\Code\XXX\ProjectXBaseDataImporter\ProjectXBaseDataImporter\CSVImporter_Test.cs:line 32
Error on my part.
Another Library I am using requires classes to have fields opposed to properties.
I was coding against the fields not properties.
I want to Minus to value in FastReport.Net in footer.
my Code :
private void PageFooter1_BeforeLayout(object sender, EventArgs e)
{
Text22.Text=Convert.ToString(Convert.ToDouble(Text12.Text)-Convert.ToDouble(Text3.Text));
}
and this error was occurs:
FastReport.Net v1.7.33
Exception has been thrown by the target of an invocation.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.FormatException: Input string was not in a correct format.
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
at FastReport.ReportScript.PageFooter1_BeforeLayout(Object sender, EventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at FastReport.Code.ExpressionDescriptor.Invoke(Object[] parameters)
at FastReport.BandBase.CalcHeight()
at FastReport.Engine.ReportEngine.ShowBandToPreparedPages(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.ShowBand(BandBase band, Boolean getData)
at FastReport.Engine.ReportEngine.EndLastPage()
at FastReport.Engine.ReportEngine.RunReportPage(ReportPage page)
at FastReport.Engine.ReportEngine.RunReportPages()
at FastReport.Engine.ReportEngine.RunReportPages(ReportPage page)
at FastReport.Engine.ReportEngine.Run(Boolean runDialogs, Boolean append, ReportPage page)
at FastReport.Report.Prepare(Boolean append)
at FastReport.Design.ReportTab.Preview()
can anyone help me ?
You can try to do DataTextFormatString="{0:Axx}", and put the code into the BeforePrint event.
For example:
private void Text14_BeforePrint(object sender, EventArgs e)
{
Text14.Text=string.Format("{0:N}",((Decimal)Report.GetColumnValue("Table.money"))-((Decimal)Report.GetColumnValue("Table.TRSMONEY")));
}
The error message below i get when I"m trying to create a new user in a project management system we use for a client. I type in all the corresponding information then when I click create it throws this error.
The following message may help in diagnosing the problem: Exception has been thrown by the target of an invocation. at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Web.Administration.WebAdminMembershipProvider.CallWebAdminMembershipProviderHelperMethodOutParams(String methodName, Object[] parameters, Type[] paramTypes) at System.Web.Administration.WebAdminMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
What causes this error is the hard drive where all databases are being stored is full. Even if there is 1kb left it will post the error. To fix, install a much larger hard drive, or clear any unnecessary files from the hard drive and make free space. the server error or asp.net error you may see from this is the 9002 error. When the hard drive is full the databases log file cannot be written too, which when anything is done to the database, inserting, updating, etc. it is written to the log file. When there is no space left the log file cannot expand therefore throwing an error. I appreciate your help chriskent. By the way if anyone is wondering we had no room left literally not even 1kb to spare, our free space was 0kb. Hope this helps.
Do you have a machine key element in your web.config? Ensure this is specifically set (Not autogenerate). Check this thread for more information:
http://forums.asp.net/t/1213872.aspx
I have a Linq-to-SQL data model that includes a type Party which is sub classed twice for Company and Individual. I am trying to bind two repeaters to Linq-to-SQL queries as follows
Dim oComp As IEnumerable(Of Company)
Dim oInd As IEnumerable(Of Individual)
oComp = From oP As Company In ERM.Parties _
Where TypeOf (oP) Is Company And _
oP.Name.StartsWith(sSearchString)
oInd = From oP As Individual In ERM.Parties _
Where TypeOf (oP) Is Individual And _
(oP.FirstName.StartsWith(sSearchString) Or _
oP.LastName.StartsWith(sSearchString))
rptIndividuals.DataSource = oInd
rptCompanies.DataSource = oComp
rptCompanies.DataBind()
rptIndividuals.DataBind()
when I step through the code oComp and oInd are IEnumerable<Company> and IEnumerable<Individual> as expected, but I get the following exception when the first DataBind call is reached
System.MissingMethodException was unhandled by user code
Message="Constructor on type 'System.Data.Linq.Provider.DataBindingList1[[DataModel.Party, DataModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' not found."
Source="mscorlib"
StackTrace:
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Data.Linq.Provider.BindingList.Create[T](DataContext context, IEnumerable1 sequence)
at System.Data.Linq.DataQuery1.GetNewBindingList()
at System.Data.Linq.DataQuery1.System.ComponentModel.IListSource.GetList()
at System.Web.UI.DataSourceHelper.GetResolvedDataSource(Object dataSource, String dataMember)
at System.Web.UI.WebControls.ReadOnlyDataSource.System.Web.UI.IDataSource.GetView(String viewName)
at System.Web.UI.WebControls.Repeater.ConnectToDataSourceView()
at System.Web.UI.WebControls.Repeater.GetData()
at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource)
at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e)
at System.Web.UI.WebControls.Repeater.DataBind()
at parties.lbHiddenPostback_Click(Object sender, EventArgs e) in \parties.aspx.vb:line 491
at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
if I then select everything as parties instead as follows, it all works ok
Dim oComp As IEnumerable(Of Party)
Dim oInd As IEnumerable(Of Party)
oComp = From oP In ERM.Parties _
Where TypeOf (oP) Is Company And _
CType(oP, Company).Name.StartsWith(sSearchString)
oInd = From oP In ERM.Parties _
Where TypeOf (oP) Is Individual And _
(CType(oP, Individual).FirstName.StartsWith(sSearchString) Or _
CType(oP, Individual).LastName.StartsWith(sSearchString))
rptIndividuals.DataSource = oInd
rptCompanies.DataSource = oComp
rptCompanies.DataBind()
rptIndividuals.DataBind()
There is nothing in either repeater that relates to the data returned yet, just a label in the item template to show me how many records are returned for each query.
It doesn't make sense to me that I have to bind to the parent type, I will be unable to access the attributes associated with Individual and Company without first casting to this type!
You can fix this by using .ToArray () when you're setting the DataSource property of the repeater...
rptCompanies.DataSource = oComp.ToArray ()
I'm not convinced I know why it works - but I tried it and it appears to solve the problem!