473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Adding a dataset to vs2005 app_code directory

Hi,

Im trying to add a dataset to the app_code directory using vs2005 \
SQL2005 beta 2. When I run through the wizard I select the option to
auto create new Stored Procedures (Select, update, delete, insert
commands) after already specifying a very basic select command that
consists of two fields.
All procedures are created fine and i'm able to save the xsd file.

Then I create a new gridview in which i use the xsd file object as my
datasource.
On execution of the gridview it binds fine and i can even click on the
edit button, but when i update with new values the following error
occurs:

ObjectDataSource 'ObjectDataSource1' could not find a non-generic
method 'NewUpdateCommand' that has parameters:

This seems like a common problem so i'm sure it's not major. Anybody
have any ideas?

Thanks

Nov 19 '05 #1
4 1733

Hi,
You created a dataset and you created the stored procedures that will
manipulate this dataset and this is all OK.
But the error message reveals that you are using also ObjectDataSource,
which requires having a method for each database operation that call the
created stored procedures.

Please take a look at this
http://msdn2.microsoft.com/en-us/library/dx70zk47 for more information.

Best regards,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
--------------------
| From: pa**@domainscanners.com
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Adding a dataset to vs2005 app_code directory
| Date: 11 Oct 2005 02:10:23 -0700
| Organization: http://groups.google.com
| Lines: 23
| Message-ID: <11**********************@o13g2000cwo.googlegroups .com>
| NNTP-Posting-Host: 81.178.3.208
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129021829 32291 127.0.0.1 (11 Oct 2005
09:10:29 GMT)
| X-Complaints-To: gr**********@google.com
| NNTP-Posting-Date: Tue, 11 Oct 2005 09:10:29 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50215),gzip(gfe),gzip(gfe)
| Complaints-To: gr**********@google.com
| Injection-Info: o13g2000cwo.googlegroups.com; posting-host=81.178.3.208;
| posting-account=nCGitg0AAAAvxAHS2Y-Y8auAS-g4JE-R
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TFEED02.phx.gbl!tornado.fa
stwebnet.it!tiscali!newsfeed1.ip.tiscali.net!news. glorb.com!postnews.google.
com!o13g2000cwo.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349885
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
|
| Im trying to add a dataset to the app_code directory using vs2005 \
| SQL2005 beta 2. When I run through the wizard I select the option to
| auto create new Stored Procedures (Select, update, delete, insert
| commands) after already specifying a very basic select command that
| consists of two fields.
| All procedures are created fine and i'm able to save the xsd file.
|
| Then I create a new gridview in which i use the xsd file object as my
| datasource.
| On execution of the gridview it binds fine and i can even click on the
| edit button, but when i update with new values the following error
| occurs:
|
| ObjectDataSource 'ObjectDataSource1' could not find a non-generic
| method 'NewUpdateCommand' that has parameters:
|
| This seems like a common problem so i'm sure it's not major. Anybody
| have any ideas?
|
| Thanks
|
|

Nov 19 '05 #2
I'm going to assume that Mahamed hasn't actually done this and that you are
in fact binding the objectdatasource to the dataset, and using the methods
generated by the datatable to execute your updates, as this is the way to
access datasets in .Net 2.0. Please correct me if this is not the case.

This is in fact the result of one of two bugs in Beta 2 (which are fixed in
the RC BTW). Even though you created these methods using the designer, and
even though you have the parameters specified in the objectdatasource
definition, it still wants to use very specific parameters and will require
that you have a method that takes certain parameters. The direct database
update methods generated do not meet this strucure. You can get around this
by modifying your procedures and updating your datatable, by wrapping your
dataset with a class that implements static (shared) methods to do the
updates and using it as your source, or by changing the
OldValuesParameterFormatString to be {0} (no old parameters essentially).
Note that to use some of the objectdatasource features such as paging, you
will be required to implement methods with specific parameters.

The other bug is more complicated, but if this doesn't work I will be happy
to explain it. Neither occur in the release candidate, so if you upgrade to
it you should be fine.

""Mohamed Sharaf"" wrote:

Hi,
You created a dataset and you created the stored procedures that will
manipulate this dataset and this is all OK.
But the error message reveals that you are using also ObjectDataSource,
which requires having a method for each database operation that call the
created stored procedures.

Please take a look at this
http://msdn2.microsoft.com/en-us/library/dx70zk47 for more information.

Best regards,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
--------------------
| From: pa**@domainscanners.com
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Subject: Adding a dataset to vs2005 app_code directory
| Date: 11 Oct 2005 02:10:23 -0700
| Organization: http://groups.google.com
| Lines: 23
| Message-ID: <11**********************@o13g2000cwo.googlegroups .com>
| NNTP-Posting-Host: 81.178.3.208
| Mime-Version: 1.0
| Content-Type: text/plain; charset="iso-8859-1"
| X-Trace: posting.google.com 1129021829 32291 127.0.0.1 (11 Oct 2005
09:10:29 GMT)
| X-Complaints-To: gr**********@google.com
| NNTP-Posting-Date: Tue, 11 Oct 2005 09:10:29 +0000 (UTC)
| User-Agent: G2/0.2
| X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;
Alexa Toolbar; .NET CLR 1.1.4322; .NET CLR 2.0.50215),gzip(gfe),gzip(gfe)
| Complaints-To: gr**********@google.com
| Injection-Info: o13g2000cwo.googlegroups.com; posting-host=81.178.3.208;
| posting-account=nCGitg0AAAAvxAHS2Y-Y8auAS-g4JE-R
| Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TFEED02.phx.gbl!tornado.fa
stwebnet.it!tiscali!newsfeed1.ip.tiscali.net!news. glorb.com!postnews.google.
com!o13g2000cwo.googlegroups.com!not-for-mail
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:349885
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi,
|
| Im trying to add a dataset to the app_code directory using vs2005 \
| SQL2005 beta 2. When I run through the wizard I select the option to
| auto create new Stored Procedures (Select, update, delete, insert
| commands) after already specifying a very basic select command that
| consists of two fields.
| All procedures are created fine and i'm able to save the xsd file.
|
| Then I create a new gridview in which i use the xsd file object as my
| datasource.
| On execution of the gridview it binds fine and i can even click on the
| edit button, but when i update with new values the following error
| occurs:
|
| ObjectDataSource 'ObjectDataSource1' could not find a non-generic
| method 'NewUpdateCommand' that has parameters:
|
| This seems like a common problem so i'm sure it's not major. Anybody
| have any ideas?
|
| Thanks
|
|

Nov 19 '05 #3
Thanks for the reply john. I've managed to do what you've said and I
actually wrote those methods in there own class.
The 'SELECT' method works fine but the minute I try and execute a
'DELETE' or 'UPDATE' method it complains there is no value present.
I started debugging this and yes it's true there was no parameter
value, it was NULL.

I'm trying to execute the following c# code:

public void DeleteItem(string Item)
{
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["ServerConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("sp_DeleteItem", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Item", SqlDbType.VarChar).Value = Item;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();
}

How do I pass the parameter value to the class method?
My datasource for the gridview seems to be setup correctly:

<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteItem"
SelectMethod="getItems" TypeName="Class1">
<DeleteParameters>
<asp:Parameter Name="Item" Type="String" />
</DeleteParameters>
</asp:ObjectDataSource>

Hope you can help.
Thanks

Nov 19 '05 #4
The key on your grid should match the parameter to the method exactly. If
they do not, it will not know what to pass to the method. In beta2 VS will
sometimes not set your data key.

"pa**@domainscanners.com" wrote:
Thanks for the reply john. I've managed to do what you've said and I
actually wrote those methods in there own class.
The 'SELECT' method works fine but the minute I try and execute a
'DELETE' or 'UPDATE' method it complains there is no value present.
I started debugging this and yes it's true there was no parameter
value, it was NULL.

I'm trying to execute the following c# code:

public void DeleteItem(string Item)
{
SqlConnection conn = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["ServerConnectionString"].ConnectionString);
SqlCommand command = new SqlCommand("sp_DeleteItem", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@Item", SqlDbType.VarChar).Value = Item;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();
}

How do I pass the parameter value to the class method?
My datasource for the gridview seems to be setup correctly:

<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DeleteMethod="DeleteItem"
SelectMethod="getItems" TypeName="Class1">
<DeleteParameters>
<asp:Parameter Name="Item" Type="String" />
</DeleteParameters>
</asp:ObjectDataSource>

Hope you can help.
Thanks

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Botha | last post by:
In VS2003 if I had a Web form, say Form1 and a class, say Class1, then I could pass the form as parameter to a sub/function in the class, so this would compile: Public Class Class1 Public Sub...
1
by: HIK | last post by:
I am trying to write a class which has a function that loads a dataset, and performs and xslt tranformtion on the dataset and returns the resulting string. In asp.net 1.1 I was able to do most...
5
by: NoNickname | last post by:
Basically, how do I know that the release versions of all components are being published? The Build | Configuration Manager is confusing me a little in VS2005. I have three projects in my...
0
by: Peter McEvoy | last post by:
Hi there, I've noticed that it does not seem to be possible to add an AssemblyInfo.cs file to a webservice project in VS2005 - although I achieved this by cutting and pasting one into the App_Code...
0
by: T. Wong | last post by:
This is a vs.net 2005/2.0 question.... In my App_Code directory I have DataSet1.xsd that has Orders DataSet and OrdersTableAdapter with FillOrders, and GetOrders methods. I have created a new...
8
by: GaryDean | last post by:
In an 2.0 asp app I used vs.net 2005 to create a TableAdapter:Dataset in my App_code directory. I also created a new vb class in that same directory. I have two issues: 1. I notice that there...
8
by: Mark Olbert | last post by:
There appears to be a REALLY annoying bug in VS2005: periodically when you're rebuilding an ASPNET2 website which uses App_Code stuff the compiler will fail to create the dynamic assembly or not be...
15
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers...
9
by: rn5a | last post by:
Is putting a VB class file in the special directory named App_Code the same as relocating the VB class file from the App_Code directory to another directory & then using the VBC tool, compiling the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.