i'm trying to update data in Access - ms-access

when I use this
con.Open();
OleDbCommand conup = new OleDbCommand(#"UPDATE [user1],
SET name = '" + textBox1.Text + "' , password ='" + textBox2.Text + "', <br>remember ='" + remember + "' WHERE (name='" + textBox1.Text + "')", con);
conup.ExecuteNonQuery();
con.Close();
it shows me an exception
System.Data.OleDb.OleDbException was unhandled,
HResult=-2147217900
Message=Syntax error in UPDATE statement.
Source=Microsoft Office Access Database Engine
ErrorCode=-2147217900
StackTrace:
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
at Sober_TAILORING.login.button1_Click(Object sender, EventArgs e) in E:\Desktop\vs project\Sober TAILORING\Sober TAILORING\login.cs:line 86
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Sober_TAILORING.Program.Main() in E:\Desktop\vs project\Sober TAILORING\Sober TAILORING\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

And password is reserved word in Access, and it makes no sense to update name, thus:
OleDbCommand conup = new OleDbCommand(#"UPDATE [user1] SET [password] = '" + textBox2.Text + "', remember = '" + remember + "' WHERE ([name] = '" + textBox1.Text + "')", con);

Related

SciChart 3.1 exception

A bit of a long-shot given that I'm using such an old version (3.1.0.4759). Users have recently started reporting the exception below when zooming on one of my application's charts. It's a bit of a pain as it can't be handled, so the whole app crashes.
It's very, very intermittent, and I've not been able to repro. The chart series does get cleared down and repopulated once a second, so the intermittent nature could be explained by (say) zooming at that specific moment in time. Having said this, I have a lot of charts throughout my app, many of which are continuously plotting, and all using the same chart modifiers, but have never noticed this problem before.
Just wondering if any of the ABT guys can shed any light on this! TIA.
System.NullReferenceException: Object reference not set to an instance of an object.
at Abt.Controls.SciChart.RangeFactory.NewWithMinMax(IRange originalRange, IComparable min, IComparable max)
at Abt.Controls.SciChart.Wpf.PcitureHelper.Zoom(IRange initialRange, Double fromCoord, Double toCoord)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.UpdateOutline(IAxis firstFont, Double currentValues, Double currentId)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.UpdateOutline(IAxis firstFont, Rect currentValues)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.OpenDatabase(Point firstFont, Point currentValues)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.OnModifierMouseUp(ModifierMouseArgs e)
at Abt.Controls.SciChart.ChartModifiers.ModifierGroup.UpdateOutline(Action2 firstFont, ModifierEventArgsBase currentValues)
at Abt.Controls.SciChart.Common.Extensions.EnumerableExtensions.CopyBuilder[firstFont](IEnumerable`1 firstFont, Action1 currentValues)
at Abt.Controls.SciChart.Utility.Mouse.MouseManager.QueueInvoker.JoinControl(Object firstFont, MouseButtonEventArgs currentValues)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
It looks like you got a NullReferenceException inside RangeFactory.NewWithMinMax
and also looks like you've customised the source-code, as the methods
at Abt.Controls.SciChart.Wpf.PcitureHelper.Zoom(IRange initialRange, Double fromCoord, Double toCoord)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.UpdateOutline(IAxis firstFont, Double currentValues, Double currentId)
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.UpdateOutline(IAxis firstFont, Rect currentValues).
at Abt.Controls.SciChart.ChartModifiers.RubberBandXyZoomModifier.OpenDatabase
are not part of the SciChart codebase.
So I'd guess that the problem lies in those methods passing invalid values to RangeFactory.
BTW the SciChart team would also tell you that v3 is pretty out of date and to ensure stability, to get up to date. That and if you get problems like this in an old version, especially in customised source-code, they can't help!

Is SQL Connection path for this ErrMsg System.Data.SqlClient.SqlException (0x80131904)

Newbie here.
It has been quite some time, could not remember the whole process of installation the SQL Server 2008 / 2008 R2.
These are the instances I found on the C: drive:
in Program Files(x86), I have
MSSQL10_50.DEVSQLEXPRESS
in Program files, I have
MSSQL10.DEVSQLEXPRESS2
MSSQL10.MSSQLSERVER
I use SSMS to connect the SQL Server instances with Windows authentication
Somehow, DEVSQLEXPRESS does not show up in SSMS (from SQL Server 2008 R2) and I can not delete it.
DEVSQLEXPRESS2 can be connected in SSMS. Now I am using DEVSQLEXPRESS2 for Asp.net Web Api for testing purpose.
This is my code. No compilation error.
public User Add(User contact)
{
try
{
SqlConnection conn = new SqlConnection("Data Source= .\\DEVSQLEXPRESS2;Initial Catalog=MyBookingHub;Integrated Security=true");
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.Text;
sqlCmd.CommandText = "INSERT INTO Users (UserName,UserPassword,UserEmailAddr,UserMobile) 
Values (#UserName,#UserPassword,#UserEmailAddr,#UserMobile)";
sqlCmd.Connection = conn;
sqlCmd.Parameters.AddWithValue("#UserName", contact.UserName);
sqlCmd.Parameters.AddWithValue("#UserPassword", contact.UserPassword);
sqlCmd.Parameters.AddWithValue("#UserEmailAddr", contact.UserEmailAddr);
sqlCmd.Parameters.AddWithValue("#UserMobileNo", contact.UserMobileNo);
conn.Open();
int rowInserted = sqlCmd.ExecuteNonQuery();
conn.Close();
var ctc = new User()
{
UserId = rowInserted,
UserName = contact.UserName,
UserPassword = contact.UserPassword,
UserEmailAddr =contact.UserEmailAddr,
UserMobileNo = contact.UserMobileNo
};
return ctc;
}
catch (Exception ex)
{
string err = ex.ToString();
return null;
}
}
This the problem encountered:
System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ' '.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at MyBookingService.DataAccessModelRepository.UserRepository.Add(User contact) in C:\Users\Edward\Documents\Visual Studio 2015__AspNet_Web_Api\MyBookingService\MyBookingService\DataAccessModelRepository\UserRepository.cs:line 82
ClientConnectionId:65379b7b-f681-459c-b98f-99e55d09fdcc
Error Number:102,State:1,Class:15
update:
Table in SQL Server:
UserId int
UserName nvarchar(30)
UserPassword nvarchar(30)
UserEmailAddr nvarchar(120)
UserMobileNo nvarchar(20)
CreatedOn datetime //Allow Null
//- use SqlDbType
sqlCmd.Parameters.Add("#UserName", SqlDbType.NVarChar, 20).Value = contact.UserName;
sqlCmd.Parameters.Add("#UserPassword", SqlDbType.NVarChar, 30).Value = contact.UserPassword;
sqlCmd.Parameters.Add("#UserEmailAddr", SqlDbType.NVarChar, 120).Value = contact.UserEmailAddr;
sqlCmd.Parameters.Add("#UserMobileNo", SqlDbType.NVarChar, 20).Value = contact.UserMobileNo;
Result is still the same as before

How to resolve Fatal Exception in vb.net?

I am working on a application and I wrote the code below,
Public Function CreateDatatable(ByVal SqlQuery As String, ByVal strTable As String, Optional ByVal OrderbyField As String = "") As DataTable
If InitDB() Then
Try
Dim sqlAdapter As New MySqlDataAdapter()
Dim dt As New DataTable()
If SqlQuery = "" Then SqlQuery = "Select * from " & strTable & IIf(OrderbyField <> "", " order by " & OrderbyField, "")
Dim cmd As New MySqlCommand(SqlQuery, MySQLCon)
cmd.CommandTimeout = 18000
sqlAdapter.SelectCommand = cmd
dt.TableName = strTable
sqlAdapter.Fill(dt)
CreateDatatable = dt
Catch ex As Exception
ServiceLog.WriteEntry("CreateDatatable Exception:" & ex.Message)
End Try
Else
CreateDatatable = Nothing
End If
End Function
After running the code this error occurred.
MySql.Data.MySqlClient.MySqlException={"Fatal error encountered during
command execution."}
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at AgilityNewsService.clsDataware_MySQL.CreateDatatable(String SqlQuery, String strTable, String OrderbyField) in C:\ISMSCleanDesktop\DesktopBkup_Tue10-22-2013\AgilityNewsService\AgilityNewsService\AgilityNewsService\clsDataware_MySQL.vb:line 48
How to resolve the above error?

MySqlDataReader.Read() throws ArgumentOutOfRangeException

I'm working with mysql .net connector 6.4.4 at win7 x64 platform. While reading data from MySqlDataReader Object, it throws exception after 18th row. But in another application I could take 40 rows without errors.
The error is just here:
MySqlDataReader.Read()
Any helps would be very appreciated.
Exception details:
System.ArgumentOutOfRangeException was unhandled
Message=Non-negative number required.
Parameter name: count
Source=mscorlib
ParamName=count
StackTrace:
at System.IO.MemoryStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at MySql.Data.MySqlClient.MySqlPacket.Read(Byte[] byteBuffer, Int32 offset, Int32 count)
at MySql.Data.MySqlClient.MySqlPacket.ReadString(Int64 length)
at MySql.Data.Types.MySqlString.MySql.Data.Types.IMySqlValue.ReadValue(MySqlPacket packet, Int64 length, Boolean nullVal)
at MySql.Data.MySqlClient.NativeDriver.ReadColumnValue(Int32 index, MySqlField field, IMySqlValue valObject)
at MySql.Data.MySqlClient.Driver.ReadColumnValue(Int32 index, MySqlField field, IMySqlValue value)
at MySql.Data.MySqlClient.ResultSet.ReadColumnData(Boolean outputParms)
at MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlDataReader.Read()
at VeriTasima.Form1..ctor() in E:\Projeler\VeriTasima\VeriTasima\Form1.cs:line 42
at VeriTasima.Program.Main() in E:\Projeler\VeriTasima\VeriTasima\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Updated:
// test
string commandString = "SELECT * FROM haber LIMIT 50";
MySqlConnection connection = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MySQL"].ConnectionString);
MySqlCommand command = new MySqlCommand(commandString, connection);
connection.Open();
MySqlDataReader sdr = command.ExecuteReader();
int count = 0;
while (sdr.Read())
{
count++;
}
sdr.Close();
sdr.Dispose();
command.Dispose();
connection.Close();
connection.Dispose();
MessageBox.Show(count.ToString());
Updated:
I fixed this problem by setting target platfrom from x86 to Any CPU. Now works properly.

WinForms ReportViewer cannot connecto to remote Report Server (SQL Express)

Introduction:
I have SQL Server Express 2008 R2 installed with Advanced Services. I have created few reports using BI Design Studio and deployed them to the Server. If I access the reporting server using IE (http://Ser2008/Reports/) it works fine (I have to put in User Name/Password). I can view reports or fool around with the settings.
Problem:
On my local machine I created a winforms application with one form containing a ReportViewer control. On form load I'm running following code:
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials =
new CustomCredentials("secret#123") {
UserName = "administrator",
Domain = "ser2008"
}.NetworkCredentials;
reportViewer1.ServerReport.ReportServerUrl = new Uri("http://ser2008/Reports/");
reportViewer1.ServerReport.ReportPath = "/Students/Attendance";
var l = new List<ReportParameter>();
l.Add(CreateParameter("UserId", "144"));
l.Add(CreateParameter("Class", "8"));
l.Add(CreateParameter("date_from", "2011-09-04"));
l.Add(CreateParameter("date_to", "2011-12-31"));
reportViewer1.ServerReport.SetParameters(l); //EXCEPTION THROWN HERE
reportViewer1.RefreshReport();
I get following exception:
The attempt to connect to the report server failed. Check your connection
information and that the report server is a compatible version. The request
failed with HTTP status 404: Not Found.
The stack trace is as follows:
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005
.Execution.RSExecutionConnection.MissingEndpointException
.ThrowIfEndpointMissing(WebException e)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005
.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn]
(RSExecutionConnection connection, ProxyMethod`1 initialMethod, ProxyMethod`1 retryMethod)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.
Execution.RSExecutionConnection.LogonUser(String userName, String password, String authority)
at Microsoft.Reporting.WinForms.ServerReport.get_Service()
at Microsoft.Reporting.WinForms.ServerReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.ServerReport.SetParameters(IEnumerable`1 parameters)
at GridEditor.ReportViewerForm.btnRefresh_Click(Object sender, EventArgs e)
in D:\TestApp\ReportViewerForm.cs:line 79
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager
.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at GridEditor.Program.Main() in D:\TestApp\Program.cs:line 16
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback
, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
CustomCredentials:
public class CustomCredentials : IReportServerCredentials
{
public string UserName { get; set; }
public SecureString Password { get; set; }
public string Domain { get; set; }
#region ctor
public CustomCredentials(string password)
{
Password = new SecureString();
foreach (char c in password.ToCharArray())
Password.AppendChar(c);
}
#endregion
#region IReportServerCredentials Members
public bool GetFormsCredentials(out Cookie authCookie, out string userName
, out string password, out string authority)
{
throw new NotImplementedException();
}
public System.Security.Principal.WindowsIdentity ImpersonationUser
{
get { throw new NotImplementedException(); }
}
public System.Net.ICredentials NetworkCredentials
{
get { return new NetworkCredential(UserName, Password, Domain); }
}
#endregion
}
UPDATE:
I have found following exception also in some place in my log file:
System.Web.Services.Protocols.SoapException: The path of the item
'/Students/Attendance/_vti_bin/ListData.svc/$metadata' is not valid. The full
path must be less than 260 characters long; other restrictions apply. If the
report server is in native mode, the path must start with slash. --->
Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException:
The path of the item '/Students/Attendance/_vti_bin/ListData.svc/$metadata' is
not valid. The full path must be less than 260 characters long; other
restrictions apply. If the report server is in native mode, the path must
start with slash.
at Microsoft.ReportingServices.WebServer.ReportingService2005Impl
.GetPermissions(String Item, String[]& Permissions)
In the end it was all trivial detail 8-)
I was using Report Manager url (http://ser2008/Reports/) where I was to use Report Server url (http://ser2008/ReportServerXp/).
Well, you should implement IReportServerCredential, and code example as follow :
public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{
// local variable for network credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{
// use NetworkCredentials
return new NetworkCredential(_UserName,_PassWord,_DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
user = password = authority = null;
return false;
}
}
then use this as follows:
IReportServerCredentials irsc = new CustomReportCredentials(userid,password, domain);
ReportViewer1.ServerReport.ReportServerCredentials = irsc;
the other code to set ServerReport property omit. hope you have a good day.