Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Thursday, March 29, 2012

Office Automation - Powerpoint in VB.Net

Hi

I tried to do the Powerpoint presentation using VB.Net 2.0. I got error while creating the object of the Powerpoint.Application

Unable to cast COM object of type 'PowerPoint.ApplicationClass' to interface type 'PowerPoint._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{91493442-5A91-11CF-8700-00AA0060263B}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).


Can any one tell me the solution for this error.?

Ganesh.

Hi Ganesh,

The error indicates that the PowerPoint.ApplicationClass was not registered on the running machine properly. A COM class needs to be registered in the registery to make it identified. The register process is done at the installation phase of Office.

So you can try to repair the installation of PowerPoint or make sure it is installed properly.

Further more, in an ASP.NET application, server side automation is not supported. Here is a KB article about this.

http://support.microsoft.com/kb/257757/en-us

Hope this helps.

office automation securiy error

Hi. While trying to create a a word document in one of my asp.net pages I
keep getting an ASP.NET permission error. first I thought it was been caused
while trying to save the document, and I added permissions for the ASP.NET
account to my folders. after that I realized that the error was being
launche at the very first line of my function:
Word.ApplicationClass WordApp = new Word.ApplicationClass();
any ideas on how to solve this?
Thanks a lot,
Alejandro.For those who need the answer visit this link:
http://www.codeproject.com/aspnet/w...9372#xx999372xx
"Alejandro Penate-Diaz" <alexware69@.hotmail.com> wrote in message
news:%239TUIGSOFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hi. While trying to create a a word document in one of my asp.net pages I
> keep getting an ASP.NET permission error. first I thought it was been
> caused while trying to save the document, and I added permissions for the
> ASP.NET account to my folders. after that I realized that the error was
> being launche at the very first line of my function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
>
>
Not to be a nark or anything, but I think the licensing for office prohibits
this sort of usage on a webserver. Or, rather, you're supposed to have a
license for office for each user using your web application. At least this
is my understanding. I'd check the EULA.
BTW, this should be unrelated to the permission problem ;)
-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hi. While trying to create a a word document in one of my asp.net
> pages I keep getting an ASP.NET permission error. first I thought it
> was been caused while trying to save the document, and I added
> permissions for the ASP.NET account to my folders. after that I
> realized that the error was being launche at the very first line of my
> function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
It's probably a security issue.
The ASPNET user account does have permission to run office by default.
You can use impersonation to have ASP.NET run under a different user account
that does have the necessary permission.
For example, you can add a line similar to this to your web.config file:
<identity impersonate="true" userName="domain\MyUserName">
password="password"/>
Here's more info on impersonation:
http://msdn.microsoft.com/library/d...personation.asp
Here's more info on generating office documents, including the wrong ways
(like office automation) and the right ways:
http://SteveOrr.net/articles/ExcelExport.aspx
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Alejandro Penate-Diaz" <alexware69@.hotmail.com> wrote in message
news:%239TUIGSOFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hi. While trying to create a a word document in one of my asp.net pages I
> keep getting an ASP.NET permission error. first I thought it was been
> caused while trying to save the document, and I added permissions for the
> ASP.NET account to my folders. after that I realized that the error was
> being launche at the very first line of my function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
>
>

office automation securiy error

Hi. While trying to create a a word document in one of my asp.net pages I
keep getting an ASP.NET permission error. first I thought it was been caused
while trying to save the document, and I added permissions for the ASP.NET
account to my folders. after that I realized that the error was being
launche at the very first line of my function:

Word.ApplicationClass WordApp = new Word.ApplicationClass();

any ideas on how to solve this?
Thanks a lot,
Alejandro.For those who need the answer visit this link:
http://www.codeproject.com/aspnet/w...9372#xx999372xx

"Alejandro Penate-Diaz" <alexware69@.hotmail.com> wrote in message
news:%239TUIGSOFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hi. While trying to create a a word document in one of my asp.net pages I
> keep getting an ASP.NET permission error. first I thought it was been
> caused while trying to save the document, and I added permissions for the
> ASP.NET account to my folders. after that I realized that the error was
> being launche at the very first line of my function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
>
Not to be a nark or anything, but I think the licensing for office prohibits
this sort of usage on a webserver. Or, rather, you're supposed to have a
license for office for each user using your web application. At least this
is my understanding. I'd check the EULA.

BTW, this should be unrelated to the permission problem ;)

-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hi. While trying to create a a word document in one of my asp.net
> pages I keep getting an ASP.NET permission error. first I thought it
> was been caused while trying to save the document, and I added
> permissions for the ASP.NET account to my folders. after that I
> realized that the error was being launche at the very first line of my
> function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
It's probably a security issue.
The ASPNET user account does have permission to run office by default.
You can use impersonation to have ASP.NET run under a different user account
that does have the necessary permission.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="true" userName="domain\MyUserName">
password="password"/
Here's more info on impersonation:
http://msdn.microsoft.com/library/d...personation.asp

Here's more info on generating office documents, including the wrong ways
(like office automation) and the right ways:
http://SteveOrr.net/articles/ExcelExport.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Alejandro Penate-Diaz" <alexware69@.hotmail.com> wrote in message
news:%239TUIGSOFHA.1476@.TK2MSFTNGP09.phx.gbl...
> Hi. While trying to create a a word document in one of my asp.net pages I
> keep getting an ASP.NET permission error. first I thought it was been
> caused while trying to save the document, and I added permissions for the
> ASP.NET account to my folders. after that I realized that the error was
> being launche at the very first line of my function:
> Word.ApplicationClass WordApp = new Word.ApplicationClass();
> any ideas on how to solve this?
> Thanks a lot,
> Alejandro.
>

Office interop from asp.net (vb) - permissions problem....

Hi,

I am trying to open a word document from an asp.net page but I keep getting
an access denied error when I try to create an instance of the word
applications.

I have created references to the Office 11.0 Object and it imported the
other references (except stdole which I did manually)

I have imported namepsaces:

Imports System.ComponentModel
Imports Microsoft.Office.Interop

The code I am calling is:

Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document
oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
oWordDoc = oWordApp.Documents.Open("c:\text.doc")

The error below says I should give access permission to the ASPNET user. But
a) that user does not exist on my machine - I think it is 'Authenticated
user' that I need and b) which file needs to be given permission?!? I have
tried giving this user full control over the entire Office folder (not
something I'd do on a production server), but no go!

Does anyone know which file needs permission? Any other suggestions?

Thanks in advance,

Stuart

================================================== ==================
The error:
Access is denied.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied.

ASP.NET is not authorized to access the requested resource. Consider
granting access rights to the resource to the ASP.NET request identity.
ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or
Network Service on IIS 6) that is used if the application is not
impersonating. If the application is impersonating via <identity
impersonate="true"/>, the identity will be the anonymous user (typically
IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET write access to a file, right-click the file in Explorer,
choose "Properties" and select the Security tab. Click "Add" to add the
appropriate user or group. Highlight the ASP.NET account, and check the
boxes for the desired access.No. ASPNET is a restricted account that's somewhat like "guest" account. It
cannot be used to execute anything outside your web process.

Instead, you should try to "impersonate"(Google for this keyword for usage)
a real "user" account, and give the "user" permission to that directory too,
of course.

"Stu" <s.lock@.cergis.com> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
> Hi,
> I am trying to open a word document from an asp.net page but I keep
> getting an access denied error when I try to create an instance of the
> word applications.
> I have created references to the Office 11.0 Object and it imported the
> other references (except stdole which I did manually)
> I have imported namepsaces:
> Imports System.ComponentModel
> Imports Microsoft.Office.Interop
> The code I am calling is:
> Dim oWordApp As Word.Application
> Dim oWordDoc As Word.Document
> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
> The error below says I should give access permission to the ASPNET user.
> But a) that user does not exist on my machine - I think it is
> 'Authenticated user' that I need and b) which file needs to be given
> permission?!? I have tried giving this user full control over the entire
> Office folder (not something I'd do on a production server), but no go!
> Does anyone know which file needs permission? Any other suggestions?
> Thanks in advance,
> Stuart
>
> ================================================== ==================
> The error:
> Access is denied.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.UnauthorizedAccessException: Access is denied.
> ASP.NET is not authorized to access the requested resource. Consider
> granting access rights to the resource to the ASP.NET request identity.
> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
> or Network Service on IIS 6) that is used if the application is not
> impersonating. If the application is impersonating via <identity
> impersonate="true"/>, the identity will be the anonymous user (typically
> IUSR_MACHINENAME) or the authenticated request user.
> To grant ASP.NET write access to a file, right-click the file in Explorer,
> choose "Properties" and select the Security tab. Click "Add" to add the
> appropriate user or group. Highlight the ASP.NET account, and check the
> boxes for the desired access.
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
news:evrIHLRjFHA.3580@.TK2MSFTNGP09.phx.gbl...
> No. ASPNET is a restricted account that's somewhat like "guest" account.
> It cannot be used to execute anything outside your web process.
> Instead, you should try to "impersonate"(Google for this keyword for
> usage) a real "user" account, and give the "user" permission to that
> directory too, of course.
> "Stu" <s.lock@.cergis.com>
> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
>> Hi,
>>
>> I am trying to open a word document from an asp.net page but I keep
>> getting an access denied error when I try to create an instance of the
>> word applications.
>>
>> I have created references to the Office 11.0 Object and it imported the
>> other references (except stdole which I did manually)
>>
>> I have imported namepsaces:
>>
>> Imports System.ComponentModel
>> Imports Microsoft.Office.Interop
>>
>> The code I am calling is:
>>
>> Dim oWordApp As Word.Application
>> Dim oWordDoc As Word.Document
>> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
>> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
>>
>> The error below says I should give access permission to the ASPNET user.
>> But a) that user does not exist on my machine - I think it is
>> 'Authenticated user' that I need and b) which file needs to be given
>> permission?!? I have tried giving this user full control over the entire
>> Office folder (not something I'd do on a production server), but no go!
>>
>> Does anyone know which file needs permission? Any other suggestions?
>>
>> Thanks in advance,
>>
>> Stuart
>>
>>
>> ================================================== ==================
>> The error:
>> Access is denied.
>> Description: An unhandled exception occurred during the execution of the
>> current web request. Please review the stack trace for more information
>> about the error and where it originated in the code.
>>
>> Exception Details: System.UnauthorizedAccessException: Access is denied.
>>
>> ASP.NET is not authorized to access the requested resource. Consider
>> granting access rights to the resource to the ASP.NET request identity.
>> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
>> or Network Service on IIS 6) that is used if the application is not
>> impersonating. If the application is impersonating via <identity
>> impersonate="true"/>, the identity will be the anonymous user (typically
>> IUSR_MACHINENAME) or the authenticated request user.
>>
>> To grant ASP.NET write access to a file, right-click the file in
>> Explorer, choose "Properties" and select the Security tab. Click "Add" to
>> add the appropriate user or group. Highlight the ASP.NET account, and
>> check the boxes for the desired access.
>>
Many thanks - that did the trick.

Stu

"Lau Lei Cheong" <leu_lc@.yehoo.com.hk> wrote in message
news:evrIHLRjFHA.3580@.TK2MSFTNGP09.phx.gbl...
> No. ASPNET is a restricted account that's somewhat like "guest" account.
> It cannot be used to execute anything outside your web process.
> Instead, you should try to "impersonate"(Google for this keyword for
> usage) a real "user" account, and give the "user" permission to that
> directory too, of course.
> "Stu" <s.lock@.cergis.com>
> glsD:OTqqejQjFHA.3144@.TK2MSFTNGP12.phx.g bl...
>> Hi,
>>
>> I am trying to open a word document from an asp.net page but I keep
>> getting an access denied error when I try to create an instance of the
>> word applications.
>>
>> I have created references to the Office 11.0 Object and it imported the
>> other references (except stdole which I did manually)
>>
>> I have imported namepsaces:
>>
>> Imports System.ComponentModel
>> Imports Microsoft.Office.Interop
>>
>> The code I am calling is:
>>
>> Dim oWordApp As Word.Application
>> Dim oWordDoc As Word.Document
>> oWordApp = New Word.Application '<<<<<<<<<<<<<<<<< ERROR
>> oWordDoc = oWordApp.Documents.Open("c:\text.doc")
>>
>> The error below says I should give access permission to the ASPNET user.
>> But a) that user does not exist on my machine - I think it is
>> 'Authenticated user' that I need and b) which file needs to be given
>> permission?!? I have tried giving this user full control over the entire
>> Office folder (not something I'd do on a production server), but no go!
>>
>> Does anyone know which file needs permission? Any other suggestions?
>>
>> Thanks in advance,
>>
>> Stuart
>>
>>
>> ================================================== ==================
>> The error:
>> Access is denied.
>> Description: An unhandled exception occurred during the execution of the
>> current web request. Please review the stack trace for more information
>> about the error and where it originated in the code.
>>
>> Exception Details: System.UnauthorizedAccessException: Access is denied.
>>
>> ASP.NET is not authorized to access the requested resource. Consider
>> granting access rights to the resource to the ASP.NET request identity.
>> ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5
>> or Network Service on IIS 6) that is used if the application is not
>> impersonating. If the application is impersonating via <identity
>> impersonate="true"/>, the identity will be the anonymous user (typically
>> IUSR_MACHINENAME) or the authenticated request user.
>>
>> To grant ASP.NET write access to a file, right-click the file in
>> Explorer, choose "Properties" and select the Security tab. Click "Add" to
>> add the appropriate user or group. Highlight the ASP.NET account, and
>> check the boxes for the desired access.
>>

Office Web Components COM error (Charting)

Hi all,
I am using the Office Web Components (Interop.OWC10.dll) to generate agrapth on my ASP.NET application and am getting the following messagefor some reason...
System.Runtime.InteropServices.COMException (0x80040154) Office Web Components
I have also referenced the following .dll's...
Interop.ADODB.dll
Interop.MSComctlLib.dll
This error occurs in a method I have called GenerateGraph(). The code contained in this method is as follows...
private void GenerateGraph()
{
try
{
//First create a ChartSpace object to hold the chart
OWC10.ChartSpaceClass objCSpace = newOWC10.ChartSpaceClass();

//Add a chart in the ChartSpace. The Add methodreturns a chart object.
OWC10.ChChart objChart = objCSpace.Charts.Add(0);
//Specify the type of the graph to be displayed. Thetype of the graph is specified by the enumerated values inOWC.ChartChartTypeEnum
objChart.Type =OWC10.ChartChartTypeEnum.chChartTypeLine;
//Give title to graph.
objChart.HasTitle = true;
objChart.Title.Caption = "Discontinuity Report";
objChart.Title.Font.Bold = true;
//Give the caption for the X axis and Y axis of thegraph
objChart.Axes[0].HasTitle = true;
objChart.Axes[0].Title.Caption = "Response Time";
objChart.Axes[0].HasTickLabels = true;
objChart.Axes[0].TickLabelSpacing = 5;
//Give the caption for the X axis and Y axis of thegraph
objChart.Axes[1].HasTitle = true;
objChart.Axes[1].Title.Caption = "Calls";
//Populate the Literal Strings For the data
//The categories and values can be given as literalstring with values separated by tabs. With these three values we candraw a single line.*/
//Dim strSeriesName As String = "Responses"
string strCategory = "";
string strValue = "";
//Add a series to the chart's series collection
objChart.SeriesCollection.Add(0);
FillDataStrings(ref strCategory, ref strValue);
//Give the name of the series
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimSeriesNames,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),""); //strSeriesName)
//Give the Categories
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimCategories,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),strCategory);
//Give The values
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimValues,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),strValue);
//Now a chart is ready to export to a GIF.
string strFilename = "PerformanceGraph" +DateTime.Now.ToString("ddMMyyyyhhmmss") + 1000 * 1000 + ".gif";
string strAbsolutePath = (Server.MapPath(".")) +"\\TempFiles\\" + strFilename;
//string strAbsolutePath = (
objCSpace.ExportPicture(strAbsolutePath, "GIF", 800,480);
//Create a relative path to the GIF file.
//If an absolute path is used instead of a relativepath, the file will not be displayed in the client machines as the fileis created in the server, not in the client. */
//string AppName =
//string strAppPath =Rainbow.Settings.Path.ApplicationPhysicalPath + "TempFiles\\" +strFilename;
string strAppPath =Rainbow.Settings.Path.ApplicationRoot + "/TempFiles/" + strFilename;
//Add the image into the placeholder.
string strImageTag = "<IMG SRC=\"" + strAppPath +"\" />";
phChart.Controls.Add(newLiteralControl(strImageTag));
Log.ApplicationLog.Write("Graph paths: \n\rApp Path:" + strAppPath + "\n\rImage Tag Path: " + strImageTag);
}
catch (Exception E)
{
Log.ApplicationLog.Write("Error: " + E);
}
}
For the life of me I can't seem to find out where exactly theproblem lies (though I have found some sources online that state thatthe the COM object may not be registered - I doubt it is this though asit would have been stated in the error message).
Hope someone can help me here.
Tryst
Which line of code is producing that error?
Did you try registering it?

regsvr32 xyz.dll
It doesn't exactly state which line it is one. It just references the method in which the error is called.
The Office Web Components were already installed as we had previous reports using the Office Web Components.
I'm not really sure what the problem can be? Are there any other possible external factors that may be causing this?
Thanks
Tryst

Try the link below for PInvoke(platform invoke). Hope this helps.
http://www.pinvoke.net
I use OWC all over the place, seems to me I get a line number. How about trying this, walk through each line of code and let us know which it dies on?
Or...
I have a little OWC Chart Helper class that I just posted at my blog. Its not very well documented, but perhaps it'll help you out? I write classes like this to help me use complicated stuff like OWC a bit more easily. I also have an Excel helper that is an interface implementing both OWC and Excel models, I'll post it soon. I need to clean these things up.
http://spaces.msn.com/members/mutethis/Blog/cns!1pqaRX9UNoMK6pqNr__0Gnqw!167.entry
HTH

Monday, March 26, 2012

ok, 2 issues

Ok, I have my first full blown .NET 05 web application 99.9% complete except
for these 2 issues. can anyone help me out?

1) If a page gets and error and the user clicks on the menu it takes them
back to the login screen. How can I prevent that from happening? If they see
the 'user friendly" error page I want them to be able to click another menu
option and go to that page without going back to the login screen. (I'm not
using the membership provider for this app)

2) on several of my pages I have several drop downs and a button. When the
user makes a selection from a drop down and clicks the button, it loads the
..NET gridView. Now I need these grids sortable. How can I accomplish this?
a) I'm NOT using an SQLObjectDataSource to bind my grid
b) if I load my grid without any drop downs I can sort, its the
grids that load
based off of a drop down selection

example:
void GetSales(string lastName)
{
binds grid based off of the last name
can't sort grid when using this
}

BUT if i do
void GetSales()
{
binds grids and I can sort the gridview
}

need help on these. thanks1. Have the page as an ASPX page instead of HTML and part of the
application. You might want to set up your own error handler in the Error
event in Global.asax that points to the ASPX error page.

2. Set up a routine that returns the dataSet to bind to teh grid. Have this
routine take the column to sort on, very similar to the samples that ship
with the SDK. Rebind after every sort click. If you do not reset your panels
(form and grid) on each click, viewstate will hold their state.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"igotyourdotnet" <igotyourdotnet@.nospam.nospamwrote in message
news:43675B27-6F7A-4D0A-BC55-E781C995BA57@.microsoft.com...

Quote:

Originally Posted by

Ok, I have my first full blown .NET 05 web application 99.9% complete
except
for these 2 issues. can anyone help me out?
>
1) If a page gets and error and the user clicks on the menu it takes them
back to the login screen. How can I prevent that from happening? If they
see
the 'user friendly" error page I want them to be able to click another
menu
option and go to that page without going back to the login screen. (I'm
not
using the membership provider for this app)
>
2) on several of my pages I have several drop downs and a button. When the
user makes a selection from a drop down and clicks the button, it loads
the
.NET gridView. Now I need these grids sortable. How can I accomplish this?
a) I'm NOT using an SQLObjectDataSource to bind my grid
b) if I load my grid without any drop downs I can sort, its the
grids that load
based off of a drop down selection
>
example:
void GetSales(string lastName)
{
binds grid based off of the last name
can't sort grid when using this
}
>
BUT if i do
void GetSales()
{
binds grids and I can sort the gridview
}
>
need help on these. thanks
>


Hello igotyourdotnet,

As for your first question, I've also found your another thread "error
trapping" in this newsgroup and some other members and our engineer Walter
have also joined in that thread. Normally, redirect to login page is caused
by the current user's associated role doesn't meet the ASP.NET(forms
authenticatino)'s authorization requirement. Is the menuitem(on the error
page) point to a page which require higher authorization permission? You
can try Gregory's suggestion on use a static html page to verify the
behavior.

As for the second question, I think basically, we can consider the
following options in ASP.NET 2.0 databinding page:

** If you do not use DataSource control to bind data to GridView, we need
to manually bind DataSource object to GridView.DataSource property
programmtically. Also, we should handle GridView.Sort event and rebind the
GridView with the sorted datasource collection. This is just like what we
do in ASP.NET 1.1 for DataGrid.

As for the Sorted DataSource object, I suggest you consider caching a
DataTable of the original data in ASP.NET cache, and when the Gridview's
Sort event fires, you retrieve the DataTable from cache and get a Sorted
DataView from the DataTable. This can help reduce the time we query the
backend database.

#GridView.Sorting Event
http://msdn2.microsoft.com/en-us/li...ntrols.gridview.
sorting.aspx

Please let me know how you get the datasource object and what's the
datasource object collection so that we can provide some further info
according to the scenario.

** Since you mentioned that you use several dropdownlists to filter the
data retrieved from database and bind them to GridView, how do those
dropdownlist's filter items work in the select query? When using
Datasource Control(SqlDataSource or ObjectDataSource) we can also configure
the DataSource control to receive paramters from other controls(like
dropdownlist, textbox ....). Therefore, if it is possible to change your
page to use those dropdownlist as paramter source of Datasource control, we
can still bind GridView to datasource control and avoid manual sorting.

Please feel free to let me know if you have any particular concerns or
difficulties here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
1 - all of my pages are aspx pages I have not HTML/HTM pages in my project at
all.

2 - I'm doing that but the grid does not sort, when I click on a row to sort
on the grid dissappears.

"Cowboy (Gregory A. Beamer)" wrote:

Quote:

Originally Posted by

1. Have the page as an ASPX page instead of HTML and part of the
application. You might want to set up your own error handler in the Error
event in Global.asax that points to the ASPX error page.
>
2. Set up a routine that returns the dataSet to bind to teh grid. Have this
routine take the column to sort on, very similar to the samples that ship
with the SDK. Rebind after every sort click. If you do not reset your panels
(form and grid) on each click, viewstate will hold their state.
>
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
>
*************************************************
Think outside of the box!
*************************************************
"igotyourdotnet" <igotyourdotnet@.nospam.nospamwrote in message
news:43675B27-6F7A-4D0A-BC55-E781C995BA57@.microsoft.com...

Quote:

Originally Posted by

Ok, I have my first full blown .NET 05 web application 99.9% complete
except
for these 2 issues. can anyone help me out?

1) If a page gets and error and the user clicks on the menu it takes them
back to the login screen. How can I prevent that from happening? If they
see
the 'user friendly" error page I want them to be able to click another
menu
option and go to that page without going back to the login screen. (I'm
not
using the membership provider for this app)

2) on several of my pages I have several drop downs and a button. When the
user makes a selection from a drop down and clicks the button, it loads
the
.NET gridView. Now I need these grids sortable. How can I accomplish this?
a) I'm NOT using an SQLObjectDataSource to bind my grid
b) if I load my grid without any drop downs I can sort, its the
grids that load
based off of a drop down selection

example:
void GetSales(string lastName)
{
binds grid based off of the last name
can't sort grid when using this
}

BUT if i do
void GetSales()
{
binds grids and I can sort the gridview
}

need help on these. thanks


>
>
>


thanks, that example is using a SQLObjectDataSource, where I'm not.
and my method to bind my grid takes parameters to get the data back from the
database

"Steven Cheng[MSFT]" wrote:

Quote:

Originally Posted by

Hello igotyourdotnet,
>
As for your first question, I've also found your another thread "error
trapping" in this newsgroup and some other members and our engineer Walter
have also joined in that thread. Normally, redirect to login page is caused
by the current user's associated role doesn't meet the ASP.NET(forms
authenticatino)'s authorization requirement. Is the menuitem(on the error
page) point to a page which require higher authorization permission? You
can try Gregory's suggestion on use a static html page to verify the
behavior.
>
As for the second question, I think basically, we can consider the
following options in ASP.NET 2.0 databinding page:
>
** If you do not use DataSource control to bind data to GridView, we need
to manually bind DataSource object to GridView.DataSource property
programmtically. Also, we should handle GridView.Sort event and rebind the
GridView with the sorted datasource collection. This is just like what we
do in ASP.NET 1.1 for DataGrid.
>
As for the Sorted DataSource object, I suggest you consider caching a
DataTable of the original data in ASP.NET cache, and when the Gridview's
Sort event fires, you retrieve the DataTable from cache and get a Sorted
DataView from the DataTable. This can help reduce the time we query the
backend database.
>
#GridView.Sorting Event
http://msdn2.microsoft.com/en-us/li...ntrols.gridview.
sorting.aspx
>
Please let me know how you get the datasource object and what's the
datasource object collection so that we can provide some further info
according to the scenario.
>
** Since you mentioned that you use several dropdownlists to filter the
data retrieved from database and bind them to GridView, how do those
dropdownlist's filter items work in the select query? When using
Datasource Control(SqlDataSource or ObjectDataSource) we can also configure
the DataSource control to receive paramters from other controls(like
dropdownlist, textbox ....). Therefore, if it is possible to change your
page to use those dropdownlist as paramter source of Datasource control, we
can still bind GridView to datasource control and avoid manual sorting.
>
Please feel free to let me know if you have any particular concerns or
difficulties here.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
>
==================================================
>
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.
>
>
>
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.
>
==================================================
>
>
>
This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>


Thanks for your reply igotyourdotnet,

Yes, the MSDN reference's example is using datasource control. Also, based
on my further research, I found that the GridView's enchanded sorting
functions are naturally designed for using Datasource control. (you can
find that the Sort method and the GridView.SortExpression and SortDirection
property are useful only when we bind Gridview with a datasource control).

However, we can still do the sorting completely without using DataSource
control(though it would be much more complex). We need to do databinding
in the Sorting event , we also need to manually record the sortexpression
and sortdirection ourself and use them to create the Sorted DataView. I
have attached a sample page which programmtically query Database and return
a DataTable(use TableAdapter/typedDataTable) and then create sorted
DataView to databind the GridView. You can get the attachment through
outlook express. Or if you feel necessary I can email it to you.

The sample page is displaying the Product table's data in Northwind
database based on a CategoryID value which is selected through a
DropDownList.

In addition, since such programmatic approach loose the natural feature of
Gridview sorting, I suggset you consider create a custom DataAccess class
to encapsulate your data query and filtering code logic and use this class
in the ObjectDataSource so that you can make use of the GridView's default
sort behavior with objectdatasource. You can provide me the detailed info
about your page's data access logic and the helper classes, I can help
create a sample page on this if necessary.

Hope this helps. If there is anything unclear, please feel free to let me
know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Ok thanks

I'm using my web browser to view the newsgroups, can you email it to me at:
igotyourdotnet at gmail dotcom?

Also from what your describing I'm kind of doing but maybe I'm missing
something in the process.

I have my UI calling my business layer which returns a dataset or datatable
from my datalayer. In the datalayer I'm calling the database via a store
procedure. So when I get my data back its already coming back as I want it
but I just need to allow the user to sort the gridview on the client in case
they want to see the data differently.

"Steven Cheng[MSFT]" wrote:

Quote:

Originally Posted by

Thanks for your reply igotyourdotnet,
>
Yes, the MSDN reference's example is using datasource control. Also, based
on my further research, I found that the GridView's enchanded sorting
functions are naturally designed for using Datasource control. (you can
find that the Sort method and the GridView.SortExpression and SortDirection
property are useful only when we bind Gridview with a datasource control).
>
However, we can still do the sorting completely without using DataSource
control(though it would be much more complex). We need to do databinding
in the Sorting event , we also need to manually record the sortexpression
and sortdirection ourself and use them to create the Sorted DataView. I
have attached a sample page which programmtically query Database and return
a DataTable(use TableAdapter/typedDataTable) and then create sorted
DataView to databind the GridView. You can get the attachment through
outlook express. Or if you feel necessary I can email it to you.
>
The sample page is displaying the Product table's data in Northwind
database based on a CategoryID value which is selected through a
DropDownList.
>
In addition, since such programmatic approach loose the natural feature of
Gridview sorting, I suggset you consider create a custom DataAccess class
to encapsulate your data query and filtering code logic and use this class
in the ObjectDataSource so that you can make use of the GridView's default
sort behavior with objectdatasource. You can provide me the detailed info
about your page's data access logic and the helper classes, I can help
create a sample page on this if necessary.
>
Hope this helps. If there is anything unclear, please feel free to let me
know.
>
Sincerely,
>
Steven Cheng
>
Microsoft MSDN Online Support Lead
>
>
>
==================================================
>
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscript...ault.aspx#notif
ications.
>
>
>
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscript...rt/default.aspx.
>
==================================================
>
>
>
This posting is provided "AS IS" with no warranties, and confers no rights


Thanks for your reply igotyourdotnet,

Yes, I've send you a mail with the attached test pages. Also, my test pages
just use a TableAdapter/typedDataTable to simulate your business object
which return datatable. And manually bind the sorted DataView(create from
the returned DataTable) to the GridView . Also, I use code to
programmatically handle the GridView's Sorting event.

Please feel free to let me know if you have any questions on the test code
or other things.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

This posting is provided "AS IS" with no warranties, and confers no rights.

Saturday, March 24, 2012

Old project - new error

the first place to start is to make sure that the project is configured as a
virtual dir and correctly mapped in IIS. Is it? If it is, run the
application without using the debugger (Ctrl+F5) option
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Mark" <anonymous@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:D503A006-F70A-4F1A-A56F-B94F962A63FC@dotnet.itags.org.microsoft.com...
> My old project is giving me that error:
> Server Error in '/processtree' Application.
> ----
--
> Configuration Error
> Description: An error occurred during the processing of a configuration
> file required to service this request. Please review the specific error
> details below and modify your configuration file appropriately.
> Parser Error Message: It is an error to use a section registered as
> allowDefinition='MachineToApplication' beyond application level. This
> error can be caused by a virtual directory not being configured as an
> application in IIS.
> Source Error:
>
> Line 44: by Microsoft that offers a single logon and core
> profile services for member sites.
> Line 45: -->
> Line 46: <authentication mode="Windows" />
> Line 47:
> Line 48: <!-- AUTHORIZATION
>
> Source File: C:\Program Files\Microsoft Visual FoxPro
> 7\testarea\dotnet\treeview\processtree\p
rocesstree\web.config Line: 46
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.573;
> ASP.NET Version:1.1.4322.573
> Can someone help me to understand what does that mean?did not help.
did not help.
Mark,
I noticed the path that was included in the error message. The very last di
rectory listed in your path needs to be marked as an application if you are
going to have a web.config file in that directory.
If I have a subdirectory/subweb under my main website and if it contains a w
eb.config, when I make that subdirectory NOT an application, I get the same
error you have listed below. It has to have something to do with the applic
ation settings associated w
ith the subdirectory.
Christopher Reed
Web Applications Supervisor
City of Lubbock
-- Mark wrote: --
My old project is giving me that error:
Server Error in '/processtree' Application.
----
--
Configuration Error
Description: An error occurred during the processing of a configuration file
required to service this request. Please review the specific error details
below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDef
inition='MachineToApplication' beyond application level. This error can be c
aused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 44: by Microsoft that offers a single logon and core profile
services for member sites.
Line 45: -->
Line 46: <authentication mode="Windows" />
Line 47:
Line 48: <!-- AUTHORIZATION
Source File: C:\Program Files\Microsoft Visual FoxPro 7\testarea\dotnet\tree
view\processtree\processtree\web.config Line: 46
----
--
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573
Can someone help me to understand what does that mean?

Old project - new error

My old project is giving me that error

Server Error in '/processtree' Application
------------------------

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS

Source Error:

Line 44: by Microsoft that offers a single logon and core profile services for member sites
Line 45: --
Line 46: <authentication mode="Windows" />
Line 47:
Line 48: <!-- AUTHORIZATION

Source File: C:\Program Files\Microsoft Visual FoxPro 7\testarea\dotnet\treeview\processtree\processtree \web.config Line: 46

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

Can someone help me to understand what does that mean?the first place to start is to make sure that the project is configured as a
virtual dir and correctly mapped in IIS. Is it? If it is, run the
application without using the debugger (Ctrl+F5) option

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/27cok
"Mark" <anonymous@.discussions.microsoft.com> wrote in message
news:D503A006-F70A-4F1A-A56F-B94F962A63FC@.microsoft.com...
> My old project is giving me that error:
> Server Error in '/processtree' Application.
> ------------------------
> Configuration Error
> Description: An error occurred during the processing of a configuration
> file required to service this request. Please review the specific error
> details below and modify your configuration file appropriately.
> Parser Error Message: It is an error to use a section registered as
> allowDefinition='MachineToApplication' beyond application level. This
> error can be caused by a virtual directory not being configured as an
> application in IIS.
> Source Error:
>
> Line 44: by Microsoft that offers a single logon and core
> profile services for member sites.
> Line 45: -->
> Line 46: <authentication mode="Windows" />
> Line 47:
> Line 48: <!-- AUTHORIZATION
>
> Source File: C:\Program Files\Microsoft Visual FoxPro
> 7\testarea\dotnet\treeview\processtree\processtree \web.config Line: 46
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:1.1.4322.573;
> ASP.NET Version:1.1.4322.573
> Can someone help me to understand what does that mean?
did not help.
did not help.

OLEDB conn giving error

Hi,
I am facing a problem while trying to execute a simple mdx query using
C# and OLEDB conn.
The code I am using is as:
// Create a OleDb(!!)-connection
OleDbConnection oleDbConn = new OleDbConnection();
// Set the connectionstring
oleDbConn.ConnectionString = "Provider=MSOLAP.2;Data
Source=localhost;Initial Catalog=FoodMart 2000;";
// Creacte a new command
OleDbCommand cmd = new OleDbCommand();
// Assign the connection to the command
cmd.Connection = oleDbConn;
// Assign a query to the commandtext
cmd.CommandText = "SELECT { [Time].&[1997] } ON COLUMNS , {
[Store].[Store State].&[WA] } ON ROWS FROM [Sales] WHERE (
[Customers].[Name].&[1370], [Measures].[Unit Sales] )";
// Open the connection
oleDbConn.Open();
// Execute the reader
OleDbDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
// for each item in the resultset, print the value
for(int i = 0; i < reader.FieldCount; i++)
{
Response.Write(reader.GetValue(i));
}
}
// Don't forget to close the connection
oleDbConn.Close();
This works fine when the 'datasource' specified is 'localhost' but
gives an exception at the 'oleDbConn.Open();' statement when i am using
any other machine name which has analysis sevices.The error is 'No
error information available: E_FAIL(0x80004005)'.
What could be the possible reasons for this.Is it authentication issue?
I dont think there is any problem with connection string.
Please Advice.
Thanks and Regards.does nobody know what to do with this.
Any help!

Thursday, March 22, 2012

OLEDB conn giving error

Hi,

I am facing a problem while trying to execute a simple mdx query using
C# and OLEDB conn.
The code I am using is as:

// Create a OleDb(!!)-connection
OleDbConnection oleDbConn = new OleDbConnection();
// Set the connectionstring
oleDbConn.ConnectionString = "Provider=MSOLAP.2;Data
Source=localhost;Initial Catalog=FoodMart 2000;";
// Creacte a new command
OleDbCommand cmd = new OleDbCommand();
// Assign the connection to the command
cmd.Connection = oleDbConn;
// Assign a query to the commandtext
cmd.CommandText = "SELECT { [Time].&[1997] } ON COLUMNS , {
[Store].[Store State].&[WA] } ON ROWS FROM [Sales] WHERE (
[Customers].[Name].&[1370], [Measures].[Unit Sales] )";
// Open the connection
oleDbConn.Open();
// Execute the reader
OleDbDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
// for each item in the resultset, print the value
for(int i = 0; i < reader.FieldCount; i++)
{
Response.Write(reader.GetValue(i));
}
}
// Don't forget to close the connection
oleDbConn.Close();

This works fine when the 'datasource' specified is 'localhost' but
gives an exception at the 'oleDbConn.Open();' statement when i am using
any other machine name which has analysis sevices.The error is 'No
error information available: E_FAIL(0x80004005)'.
What could be the possible reasons for this.Is it authentication issue?
I dont think there is any problem with connection string.

Please Advice.
Thanks and Regards.does nobody know what to do with this.
Any help!

OLEDB DATAREADER NOT WORKING

Hello, I am using the code down below and I keep receiving the error: No
value given for one or more required parameters.
What am I doing wrong?
protected void dgCustomerSearch_Sort(object sender, EventArgs e)
{
string strCustomerSearchQry;
string strSortExp = dgCustomerSearch.SortExpression.ToString();
strCustomerSearchQry = txtSearchCustomer.Text;
lblCustSrchNotValid.Visible = false;
string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
Source=" + MapPath("cpaneldb.mdb");
OleDbConnection objConString = new OleDbConnection(srcConString);
string srcCmd = "SELECT * FROM tbl_customers WHERE
((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
tbl_customers.[" + strSortExp + "]";
objConString.Open();
OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
OleDbDataReader objRdr;
objRdr = objCmd.ExecuteReader();
dgCustomerSearch.DataSource = objRdr;
dgCustomerSearch.DataBind();
objRdr.Close();
objConString.Close();
dgCustomerSearch.Visible = true;
}Take the completed srcCmd string, copy it into SQL queryAnalyzer, and execut
e
it.
You will see what is wrong.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"John Chapman" wrote:

> Hello, I am using the code down below and I keep receiving the error: No
> value given for one or more required parameters.
> What am I doing wrong?
> protected void dgCustomerSearch_Sort(object sender, EventArgs e)
> {
> string strCustomerSearchQry;
> string strSortExp = dgCustomerSearch.SortExpression.ToString();
> strCustomerSearchQry = txtSearchCustomer.Text;
> lblCustSrchNotValid.Visible = false;
> string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
> Source=" + MapPath("cpaneldb.mdb");
> OleDbConnection objConString = new OleDbConnection(srcConString);
> string srcCmd = "SELECT * FROM tbl_customers WHERE
> ((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
> (tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
> tbl_customers.[" + strSortExp + "]";
> objConString.Open();
> OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
> OleDbDataReader objRdr;
> objRdr = objCmd.ExecuteReader();
> dgCustomerSearch.DataSource = objRdr;
> dgCustomerSearch.DataBind();
> objRdr.Close();
> objConString.Close();
> dgCustomerSearch.Visible = true;
> }
>

OLEDB DATAREADER NOT WORKING

Hello, I am using the code down below and I keep receiving the error: No
value given for one or more required parameters.

What am I doing wrong?

protected void dgCustomerSearch_Sort(object sender, EventArgs e)
{
string strCustomerSearchQry;
string strSortExp = dgCustomerSearch.SortExpression.ToString();
strCustomerSearchQry = txtSearchCustomer.Text;
lblCustSrchNotValid.Visible = false;

string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
Source=" + MapPath("cpaneldb.mdb");
OleDbConnection objConString = new OleDbConnection(srcConString);
string srcCmd = "SELECT * FROM tbl_customers WHERE
((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
tbl_customers.[" + strSortExp + "]";
objConString.Open();
OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
OleDbDataReader objRdr;
objRdr = objCmd.ExecuteReader();
dgCustomerSearch.DataSource = objRdr;
dgCustomerSearch.DataBind();
objRdr.Close();
objConString.Close();
dgCustomerSearch.Visible = true;
}Take the completed srcCmd string, copy it into SQL queryAnalyzer, and execute
it.
You will see what is wrong.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"John Chapman" wrote:

Quote:

Originally Posted by

Hello, I am using the code down below and I keep receiving the error: No
value given for one or more required parameters.
>
What am I doing wrong?
>
protected void dgCustomerSearch_Sort(object sender, EventArgs e)
{
string strCustomerSearchQry;
string strSortExp = dgCustomerSearch.SortExpression.ToString();
strCustomerSearchQry = txtSearchCustomer.Text;
lblCustSrchNotValid.Visible = false;
>
string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
Source=" + MapPath("cpaneldb.mdb");
OleDbConnection objConString = new OleDbConnection(srcConString);
string srcCmd = "SELECT * FROM tbl_customers WHERE
((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER BY
tbl_customers.[" + strSortExp + "]";
objConString.Open();
OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
OleDbDataReader objRdr;
objRdr = objCmd.ExecuteReader();
dgCustomerSearch.DataSource = objRdr;
dgCustomerSearch.DataBind();
objRdr.Close();
objConString.Close();
dgCustomerSearch.Visible = true;
}
>


Thank you, I actually found that the issue was that the way I was
retrieving the sort expression returned nothing. So it was looking to sort
by a blank field.

"Peter Bromberg [C# MVP]" <pbromberg@.yahoo.yabbadabbadoo.comwrote in
message news:E76C3BF9-193D-4C3D-8923-39A4B1DEED05@.microsoft.com...

Quote:

Originally Posted by

Take the completed srcCmd string, copy it into SQL queryAnalyzer, and
execute
it.
You will see what is wrong.
Peter
>
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
>
>
>
>
"John Chapman" wrote:
>

Quote:

Originally Posted by

>Hello, I am using the code down below and I keep receiving the error: No
>value given for one or more required parameters.
>>
>What am I doing wrong?
>>
>protected void dgCustomerSearch_Sort(object sender, EventArgs e)
> {
> string strCustomerSearchQry;
> string strSortExp = dgCustomerSearch.SortExpression.ToString();
> strCustomerSearchQry = txtSearchCustomer.Text;
> lblCustSrchNotValid.Visible = false;
>>
> string srcConString = "Provider=Microsoft.Jet.OleDb.4.0;Data
>Source=" + MapPath("cpaneldb.mdb");
> OleDbConnection objConString = new OleDbConnection(srcConString);
> string srcCmd = "SELECT * FROM tbl_customers WHERE
>((tbl_customers.[ID] LIKE '%" + strCustomerSearchQry + "%') OR
>(tbl_customers.[LASTNAME] LIKE '%" + strCustomerSearchQry + "%')) ORDER
>BY
>tbl_customers.[" + strSortExp + "]";
> objConString.Open();
> OleDbCommand objCmd = new OleDbCommand(srcCmd, objConString);
> OleDbDataReader objRdr;
> objRdr = objCmd.ExecuteReader();
> dgCustomerSearch.DataSource = objRdr;
> dgCustomerSearch.DataBind();
> objRdr.Close();
> objConString.Close();
> dgCustomerSearch.Visible = true;
> }
>>

OleDbConnection is not defined.

Hi!
I get the following error when connecting to my database. What am I missing? Please help, its driving me crazy!

Compiler Error Message:BC30002: Type 'OleDbConnection' is not defined.
Source Error:
Line 10: Dim objConnection As OleDbConnection

This is my code:
<%@dotnet.itags.org. Page Language="VB" %>
<%@dotnet.itags.org. import Namespace="System" %>
<%@dotnet.itags.org. import Namespace="System.Data" %>
<%@dotnet.itags.org. import Namespace="Sysyem.Data.OleDb" %>
<script runat="server">
    Sub Page_Load(Source As Object, E As EventArgs)
Dim objConnection As OleDbConnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA SOURCE=C:\..\foods.mdb")
objConnection.Open()
...
Add this to the top of you code behind page...

Imports System.Data.OleDb

Oopps, just looked closer at your code... nevermind.
You must not be using VS.Net.
You have it imported and it should work.

Zath


Nope, no VS.NET for me! I'm using webmatrix. I thought it should work, is there something I could be leaving out - like setting it up through ODBC administrator?
Crab


Crab wrote:

This is my code:
<%@. Page Language="VB" %>
<%@. import Namespace="System" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="Sysyem.Data.OleDb" %>


You've misspelled the namespace. Try
System.Data.OleDb

Good catch. I didn't even notice that.....
Doh! I can't believe how many times I read over that and didn't see it. Thanks!
Doh! I can't believe how many times I read over that and didn't see it. Thanks!
Now I have a problem with my datareader! any more help?
Compiler Error Message:BC30201: Expression expected.
Source Error:
Line 22: & "</b></td><td>" & objDataReader("Weight") & "</td><td>" _Line 23: & objDataReader("Price") & "</td></tr>" & _Line 24: & "<tr><td colspan='3'>" & objDatareader("Description") _Line 25: & "</td></tr>"Line 26: Loop

Did you check whether you have null values into your Description column? Another way is allowing null values against that column

There are no null values in any of the columns used. I can't work it out.


Can we see more of your code? I am curious why you are outputting your data in that manner.

S'ok, it was an extra & at the end of line 23. I'm doing an exercise from as asp.net book that was using the datarepeater to display the datasource.
Thanks for your help!

OleDbConnection syntax error

I'm having a format error with OleDbConnection (Format of the
initialization string does not conform to specification starting at
index 0) with the following. (The line referred to by the compiler isI
flagged with: <-- problem) . I use ASP.NET 2.0.

TIA for any hints, Mark

<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %>

Dim objDataSet As New DataSet()
Dim objDataAdapter As New OleDbDataAdapter()
Dim strConnection As String =
ConfigurationManager.ConnectionStrings("DbConn").ConnectionString

Dim objConnection As New OleDbConnection(strConnection) <-- format
error

objConnection.Open()
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet)

grd2.DataSource = objDataAdapter.SelectCommand
grd2.DataBind()

where (web.config):
<connectionStrings>
<add name="DbConn"
connectionString="~/App_Data/CRM2K_be.mdb"
providerName="System.Data.OleDb"/>
</connectionStrings>I found a workaround, but this is contrary to the samples I have seen
so far.

The following works:

Dim objConnection As New
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" &
Server.MapPath("App_Data/CRM2K_be.mdb;"))

However, with DbConn defined in web.config as above yields an error::

Dim strConn As String =
ConfigurationManager.ConnectionStrings("DbConn").ConnectionString
Dim objConnection As New OleDbConnection(strConn)

fails presumably because it returns a fraction of the connection
string, since:

Response.Write(strConn) = '~/App_Data/CRM2K_be.mdb'

What is the correct syntax for web.config declarations? TIA, Mark
I believe the correct connection string should be:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;"

Additionally, the "~" is not understood by OleDB because it's a server
construct for ASP.NET.

Hope this works!
--
Christopher A. Reed
"The oxen are slow, but the earth is patient."

<msch-prv@.bluewin.chwrote in message
news:1153306561.232119.278120@.b28g2000cwb.googlegr oups.com...

Quote:

Originally Posted by

I'm having a format error with OleDbConnection (Format of the
initialization string does not conform to specification starting at
index 0) with the following. (The line referred to by the compiler isI
flagged with: <-- problem) . I use ASP.NET 2.0.
>
TIA for any hints, Mark
>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.Data.OleDb" %>
>
Dim objDataSet As New DataSet()
Dim objDataAdapter As New OleDbDataAdapter()
Dim strConnection As String =
ConfigurationManager.ConnectionStrings("DbConn").ConnectionString
>
Dim objConnection As New OleDbConnection(strConnection) <-- format
error
>
objConnection.Open()
Dim objCommand As New OleDbCommand(strSQL, objConnection)
objDataAdapter.SelectCommand = objCommand
objDataAdapter.Fill(objDataSet)
>
grd2.DataSource = objDataAdapter.SelectCommand
grd2.DataBind()
>
where (web.config):
<connectionStrings>
<add name="DbConn"
connectionString="~/App_Data/CRM2K_be.mdb"
providerName="System.Data.OleDb"/>
</connectionStrings>
>


Thanks Christopher,

It works now after editing the connection strings in web.config:

<connectionStrings>
<add name="DbConn"
connectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
SOURCE=|DataDirectory|\CRM2K_be.md"
providerName="System.Data.OleDb"/>
</connectionStrings>

OleDbException executing reader on Access stored view

I had a strange error in asp.net when try to execute a simple select
statement like "Select * From ViewName" if the stored view contains a where
clause.
The connection is made to an Access database using System.Data.OleDb objects
and Jet 4.0 oledb provider.
The same code works fine in windows form application.
Removing the where clause from the stored view or adding ASPNET user into
"Power Users" or "Administrators" groups, all works also in asp.net.
My first idea was a security/permission problem, but it is strange that all
properly works without the where clause.

The error happens on Win xp sp2 with .NET 1.1 sp1 and don't happens on Win
xp sp1 with .NET 1.1 sp1.

???
Some ideas?

Thanks so much for your help, Marco.Exceptions have messages. Odd that you danced all around the exception
without managing to mention what exactly it IS. How about it?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Marco Frontini" <iunknown@.libero.it> wrote in message
news:ucslziM%23EHA.2156@.TK2MSFTNGP10.phx.gbl...
>I had a strange error in asp.net when try to execute a simple select
>statement like "Select * From ViewName" if the stored view contains a
>where clause.
> The connection is made to an Access database using System.Data.OleDb
> objects and Jet 4.0 oledb provider.
> The same code works fine in windows form application.
> Removing the where clause from the stored view or adding ASPNET user into
> "Power Users" or "Administrators" groups, all works also in asp.net.
> My first idea was a security/permission problem, but it is strange that
> all properly works without the where clause.
> The error happens on Win xp sp2 with .NET 1.1 sp1 and don't happens on Win
> xp sp1 with .NET 1.1 sp1.
> ???
> Some ideas?
> Thanks so much for your help, Marco.
A generic "Internal OLE Automation Error" isn't so usefull.

"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> ha scritto nel messaggio
news:O8pWebN%23EHA.1296@.TK2MSFTNGP10.phx.gbl...
> Exceptions have messages. Odd that you danced all around the exception
> without managing to mention what exactly it IS. How about it?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Neither a follower nor a lender be.
> "Marco Frontini" <iunknown@.libero.it> wrote in message
> news:ucslziM%23EHA.2156@.TK2MSFTNGP10.phx.gbl...
>>I had a strange error in asp.net when try to execute a simple select
>>statement like "Select * From ViewName" if the stored view contains a
>>where clause.
>> The connection is made to an Access database using System.Data.OleDb
>> objects and Jet 4.0 oledb provider.
>> The same code works fine in windows form application.
>> Removing the where clause from the stored view or adding ASPNET user into
>> "Power Users" or "Administrators" groups, all works also in asp.net.
>> My first idea was a security/permission problem, but it is strange that
>> all properly works without the where clause.
>>
>> The error happens on Win xp sp2 with .NET 1.1 sp1 and don't happens on
>> Win xp sp1 with .NET 1.1 sp1.
>>
>> ???
>> Some ideas?
>>
>> Thanks so much for your help, Marco.
>>

OleDbException executing reader on Access stored view

I had a strange error in asp.net when try to execute a simple select
statement like "Select * From ViewName" if the stored view contains a where
clause.
The connection is made to an Access database using System.Data.OleDb objects
and Jet 4.0 oledb provider.
The same code works fine in windows form application.
Removing the where clause from the stored view or adding ASPNET user into
"Power Users" or "Administrators" groups, all works also in asp.net.
My first idea was a security/permission problem, but it is strange that all
properly works without the where clause.
The error happens on Win xp sp2 with .NET 1.1 sp1 and don't happens on Win
xp sp1 with .NET 1.1 sp1.
'?
Some ideas?
Thanks so much for your help, Marco.Exceptions have messages. Odd that you danced all around the exception
without managing to mention what exactly it IS. How about it?
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.
"Marco Frontini" <iunknown@.libero.it> wrote in message
news:ucslziM%23EHA.2156@.TK2MSFTNGP10.phx.gbl...
>I had a strange error in asp.net when try to execute a simple select
>statement like "Select * From ViewName" if the stored view contains a
>where clause.
> The connection is made to an Access database using System.Data.OleDb
> objects and Jet 4.0 oledb provider.
> The same code works fine in windows form application.
> Removing the where clause from the stored view or adding ASPNET user into
> "Power Users" or "Administrators" groups, all works also in asp.net.
> My first idea was a security/permission problem, but it is strange that
> all properly works without the where clause.
> The error happens on Win xp sp2 with .NET 1.1 sp1 and don't happens on Win
> xp sp1 with .NET 1.1 sp1.
> '?
> Some ideas?
> Thanks so much for your help, Marco.
>
A generic "Internal OLE Automation Error" isn't so usefull.
"Kevin Spencer" <kevin@.DIESPAMMERSDIEtakempis.com> ha scritto nel messaggio
news:O8pWebN%23EHA.1296@.TK2MSFTNGP10.phx.gbl...
> Exceptions have messages. Odd that you danced all around the exception
> without managing to mention what exactly it IS. How about it?
> --
> HTH,
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> Neither a follower nor a lender be.
> "Marco Frontini" <iunknown@.libero.it> wrote in message
> news:ucslziM%23EHA.2156@.TK2MSFTNGP10.phx.gbl...
>

OleDbException: Too many arguments.

Hi,

I'm passing around 30 arguments to a stored procedure, and
I got the following error (see below).
It works fine if I narrow down to around 25 args. Is there
any workaround to bypass this exception, I need to pass 30
of them to my stored procedure. Thanks.
I'm using Framework 1.0.

--------
Too many arguments.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Too
many arguments.

Source Error:

Line 663:
Line 664: 'execute SQL
Line 665: oCmd.ExecuteNonQuery()
Line 666:
Line 667: 'Catch exc As OleDbException
--------If you have any return parameters, they must be specified first. You should
declare any return parameters before you start adding input parameters. That
is commonly the reason for this error. Also, make sure that the order in
which you are adding your parameters match the order in the stored
procedure.

HTH,
Bill P.

"jn" <anonymous@.discussions.microsoft.com> wrote in message
news:001001c3aec9$13cedf10$a501280a@.phx.gbl...
> Hi,
> I'm passing around 30 arguments to a stored procedure, and
> I got the following error (see below).
> It works fine if I narrow down to around 25 args. Is there
> any workaround to bypass this exception, I need to pass 30
> of them to my stored procedure. Thanks.
> I'm using Framework 1.0.
> --------
> Too many arguments.
> Description: An unhandled exception occurred during the
> execution of the current web request. Please review the
> stack trace for more information about the error and where
> it originated in the code.
> Exception Details: System.Data.OleDb.OleDbException: Too
> many arguments.
> Source Error:
>
> Line 663:
> Line 664: 'execute SQL
> Line 665: oCmd.ExecuteNonQuery()
> Line 666:
> Line 667: 'Catch exc As OleDbException
> --------
arg, I found out it's Visual FoxPro problem (I'm using VFP
as the backend database), it just won't take more than 28
parameters. Thanks, Bill, for looking into my problem
though.

>--Original Message--
>If you have any return parameters, they must be specified
first. You should
>declare any return parameters before you start adding
input parameters. That
>is commonly the reason for this error. Also, make sure
that the order in
>which you are adding your parameters match the order in
the stored
>procedure.
>HTH,
>Bill P.
>
>"jn" <anonymous@.discussions.microsoft.com> wrote in
message
>news:001001c3aec9$13cedf10$a501280a@.phx.gbl...
>> Hi,
>>
>> I'm passing around 30 arguments to a stored procedure,
and
>> I got the following error (see below).
>> It works fine if I narrow down to around 25 args. Is
there
>> any workaround to bypass this exception, I need to pass
30
>> of them to my stored procedure. Thanks.
>> I'm using Framework 1.0.
>>
>> --------
>> Too many arguments.
>> Description: An unhandled exception occurred during the
>> execution of the current web request. Please review the
>> stack trace for more information about the error and
where
>> it originated in the code.
>>
>> Exception Details: System.Data.OleDb.OleDbException: Too
>> many arguments.
>>
>> Source Error:
>>
>>
>> Line 663:
>> Line 664: 'execute SQL
>> Line 665: oCmd.ExecuteNonQuery()
>> Line 666:
>> Line 667: 'Catch exc As OleDbException
>> --------
>>
>
>.

OleDbException: Data type mismatch in criteria expression.

Using Access db with VS2008 (ASP.NET/VB.NET)...
On the INSERT command I get this error: System.Data.OleDb.OleDbException:
Data type mismatch in criteria expression.
I haven't found a solution yet in my research. Any idea what I might be
missing?
**************
Datasource setup as follows:
<asp:AccessDataSource ID="AccessDataSource1"
runat="server"
DataFile="~/BeachFuneral.mdb"
InsertCommand="INSERT INTO [ObitComments]
([ObitId], [CommentBy], [CommentEmail], [CommentRelation],
[CommentApproved], [CommentDateTime], [ObitComment]) VALUES (?, ?, ?, ?, ?,
?, ?)" >
<InsertParameters>
<asp:Parameter Name="ObitId" />
<asp:Parameter Name="CommentBy" />
<asp:Parameter Name="CommentEmail" />
<asp:Parameter Name="CommentRelation" />
<asp:Parameter Name="CommentApproved" />
<asp:Parameter Name="CommentDateTime" />
<asp:Parameter Name="ObitComment" />
</InsertParameters>
</asp:AccessDataSource>
**************
Code to insert as follows:
With Me.AccessDataSource1
.InsertParameters("ObitId").DefaultValue =
Request.QueryString("Id")
.InsertParameters("CommentBy").DefaultValue =
Me.txtFullName.Text
.InsertParameters("CommentEmail").DefaultValue =
Me.txtEmail.Text
.InsertParameters("CommentRelation").DefaultValue =
Me.txtRelationship.Text
.InsertParameters("CommentApproved").DefaultValue = True
.InsertParameters("CommentDateTime").DefaultValue = Now.ToString
.InsertParameters("ObitComment").DefaultValue =
Me.txtComment.Text
End With
Try
Me.AccessDataSource1.Insert()
Catch ex As Exception
Response.Write(ex.ToString)
Exit Sub
Finally
' if ok then move on...
Response.Redirect("Obit.aspx?Id=" & Request.QueryString("Id"))
End TryYou have not identified what data types your database is using, either in
this message, or in your code. However, you are attemtping to insert all
string values (text data type), with the exception of one field
(CommentApproved) which you are inserting a boolean value into. So, unless
all of the fields in the table are text except for that one, you would
certainly get that exception.
HTH,
Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
"Bobby Edward" <test@.test.com> wrote in message
news:OkUo0QofIHA.288@.TK2MSFTNGP02.phx.gbl...
> Using Access db with VS2008 (ASP.NET/VB.NET)...
> On the INSERT command I get this error: System.Data.OleDb.OleDbException:
> Data type mismatch in criteria expression.
> I haven't found a solution yet in my research. Any idea what I might be
> missing?
> **************
> Datasource setup as follows:
> <asp:AccessDataSource ID="AccessDataSource1"
> runat="server"
> DataFile="~/BeachFuneral.mdb"
> InsertCommand="INSERT INTO [ObitComments]
> ([ObitId], [CommentBy], [CommentEmail], [CommentRelation],
> [CommentApproved], [CommentDateTime], [ObitComment]) VALUES (?, ?, ?, ?,
> ?, ?, ?)" >
> <InsertParameters>
> <asp:Parameter Name="ObitId" />
> <asp:Parameter Name="CommentBy" />
> <asp:Parameter Name="CommentEmail" />
> <asp:Parameter Name="CommentRelation"
> />
> <asp:Parameter Name="CommentApproved"
> />
> <asp:Parameter Name="CommentDateTime"
> />
> <asp:Parameter Name="ObitComment" />
> </InsertParameters>
> </asp:AccessDataSource>
> **************
> Code to insert as follows:
> With Me.AccessDataSource1
> .InsertParameters("ObitId").DefaultValue =
> Request.QueryString("Id")
> .InsertParameters("CommentBy").DefaultValue =
> Me.txtFullName.Text
> .InsertParameters("CommentEmail").DefaultValue =
> Me.txtEmail.Text
> .InsertParameters("CommentRelation").DefaultValue =
> Me.txtRelationship.Text
> .InsertParameters("CommentApproved").DefaultValue = True
> .InsertParameters("CommentDateTime").DefaultValue =
> Now.ToString
> .InsertParameters("ObitComment").DefaultValue =
> Me.txtComment.Text
> End With
> Try
> Me.AccessDataSource1.Insert()
> Catch ex As Exception
> Response.Write(ex.ToString)
> Exit Sub
> Finally
> ' if ok then move on...
> Response.Redirect("Obit.aspx?Id=" & Request.QueryString("Id"))
> End Try
>
>

Wednesday, March 21, 2012

OleDbParameters, Pls help...

Hi, im trying to insert this paragraph to Access Db,

Miniplast <T-Piece> Welding Machine

But it show me error as below:
Server Error in '/' Application.
------------------------

A potentially dangerous Request.Form value was detected from the client (tb0="...niplast 2 <T-Piece> Welding Ma...").
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (tb0="...niplast 2 <T-Piece> Welding Ma...").

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (tb0="...niplast 2 <T-Piece> Welding Ma...").]
System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +230
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +99
System.Web.HttpRequest.get_Form() +121
System.Web.UI.Page.GetCollectionBasedOnMethod() +70
System.Web.UI.Page.DeterminePostBackMode() +47
System.Web.UI.Page.ProcessRequestMain() +2106
System.Web.UI.Page.ProcessRequest() +218
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87

Here is my code


Dim strsql as string= "INSERT INTO ToolNAccessories (Name, Descrip, Price) VALUES" & _
"( @dotnet.itags.org.Params0, @dotnet.itags.org.Params1, @dotnet.itags.org.Params2)"
Dim objCmd as New OleDbCommand(StrSql, Conn)
Dim Objparam as OleDbParameter

With ObjCmd.Parameters:
.Add(New OleDbParameter("@dotnet.itags.org.Params0", Tb0.Text))
.Add(New OleDbParameter("@dotnet.itags.org.Params1", Tb1.Text))
.Add(New OleDbParameter("@dotnet.itags.org.Params2", Tb2.Text))
End With
Conn.Open()
ObjCmd.ExecuteNonQuery()
Conn.Close()

This piece of code was working very well until i insert


Miniplast <T-Piece> Welding Machine

This sound like Sql injection... how can it be... im using parameters to prevent it already right?

Any idea what happened? Pls guard me on tis..

Thanks in advance
life's NgOn the page, in the @.page directive, add ValidateRequest="false". This will allow the < and > character in posted data, but you should then check for script injection.
Thanks douglas,

oh my God.... now i then realize there is sooo much injections we gonna deal with... :(

Mr douglas, i dont think im going to set validateRequest="false"... but I having some questions in my mind..

1. Will my previous error let any attacker getting some clues to proceed their job?

2. Can i try some "weird" characters like <>)*&%$^&* for some user's input on any website? is that illegal? i just wish to try out see whether the web application is secure from this aspect.. will that made a web server down or something?

Best Regards
life's Ng
Hi Douglas,

I wonder if i set validateRequest="false" , all i need to check is script injection using "Server.HtmlEncode" is tat correct? Anything else i need to consider?

Regards
life's Ng
If it is acceptable to have users enter < or >, then you will need to set ValidateRequest="false". Failing that, you should think about handling the error in a somewhat more elegant way. I am not totally certain that will address all the issues. Anyone else who has looked at this more closely?

Friday, March 16, 2012

Omitting columns from Stored Procedures, DAL, BLL and PL

I have been trying to do this with no luck. I get an 'Exception has been thrown by the target of the invocation.' error after the End Get here.

PrivateReadOnlyProperty Adapter()As System.Data.SqlClient.SqlDataAdapter

Get

If (Me._adapterIsNothing)Then

Me.InitAdapter

EndIf

ReturnMe._adapter

EndGet

EndProperty

The app setup is an SQL Server / Stored Procedured / UDFs // DAL / BLL / PL. I omitted two columns from the table. The columns are currently being used by another app but are being phased out with this new app so they will eventually be deleted. Is this the proper way to do this or do I have to include them in the SP / DAL / BLL until the columns are actually deleted?

Your new application should be able to completely ignore the 2 columns you are depreciating, provided that the two columns are marked as allowing null values.

If the two column "are" marked as allowing null values and it is generating this error, I suppose you could check for triggers or dependencies on the columns. Otherwise your error is probably coming from somewhere else other than the missing 2 columns.