473,795 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best approach - databound controls & ADO.NET

Hi Everyone,
I'm currently using VS 2005 and would like to use the databinding of the
controls to help ease up some of the coding I have to do (some of my forms
have over 120 fields). The problem I find is that in the database we are
currently creating the primary key within the stored procedure like so:
Declare @LastValue int
Set @LastValue = (Select ScreeningId from Support)
set @LastValue = @LastValue + 1
Update Support
Set ScreeningId = @LastValue
/THe insert code would follow using LastValue as the primary key/

I found I had problems with inserting new records when I used databound
controls. It would through errors about invalid use as null for the primary
key. I was wondering if anyone else has run across this and how they solved
this problem, or if you found a better solution. The form I'm currently
working on has little over 150 fields and it has taken a while to code each
field for the Insert, Update and setting the data for the field. I hope
someone would have any suggestions. Thanks.
Michael

Jan 20 '06 #1
6 1748
Michael,

I hope that the 120 fields are not in one database table. All wizards in
visual Studio do only work for tables with less than 101 fields.

Otherwise generating a strongly typed dataset in a windowform project will
give you all the commands you need. You can than port them to your SP with
copy and paste.

They are created in the dataset.designe r.vb

(If a table is more than 100 you can use only 100 and than add the one which
exceed those).

A command is named in the dataadapter by the commands as there are
updatecommand.c ommandtype = commandtype.sto redprocedure
updatecommand.c ommandtext = (name of your stored procedure)

http://msdn.microsoft.com/library/de...mmandtopic.asp

http://msdn.microsoft.com/library/de...mberstopic.asp

By the way in fact is there a special newsgroup for this kind of questions.

microsoft.publi c.dotnet.framew ork.adonet

I hope this helps,

Cor
Jan 20 '06 #2
Hi Cor,
thanks for the reply. I guess I'm in trouble then. The table I'm currently
working with has the data split into two table (I think I should break it
down more based on what you said about the 101 field limit). On of the tables
have 256 fields and the other has 186 fields. I'm creating a app to replace
medical type forms.
I'm currently using the command object with the stored procs and it works,
it just ALOT of typing (or copy paste). I did write a little app to create
the stored procs and the base Save/Update vb functions based on whats in the
database, but I still have alot to code.
I will try it again, but if I recall, When I did try the bound controls, I
did have it setup with the dataadapter/command objects and setup a datatable
with relations. Maybe that was what caused my problems, can't remember for
sure (been a few months ago). I'll take another look and see if I can get it
to work.
Thanks again for the reply and any suggestion.
Michael

"Cor Ligthert [MVP]" wrote:
Michael,

I hope that the 120 fields are not in one database table. All wizards in
visual Studio do only work for tables with less than 101 fields.

Otherwise generating a strongly typed dataset in a windowform project will
give you all the commands you need. You can than port them to your SP with
copy and paste.

They are created in the dataset.designe r.vb

(If a table is more than 100 you can use only 100 and than add the one which
exceed those).

A command is named in the dataadapter by the commands as there are
updatecommand.c ommandtype = commandtype.sto redprocedure
updatecommand.c ommandtext = (name of your stored procedure)

http://msdn.microsoft.com/library/de...mmandtopic.asp

http://msdn.microsoft.com/library/de...mberstopic.asp

By the way in fact is there a special newsgroup for this kind of questions.

microsoft.publi c.dotnet.framew ork.adonet

I hope this helps,

Cor

Jan 20 '06 #3
I really feel sorry for the poor blokes who will have to fill out your form
or even read your form with 150 fields!
--
Dennis in Houston
"Michael" wrote:
Hi Cor,
thanks for the reply. I guess I'm in trouble then. The table I'm currently
working with has the data split into two table (I think I should break it
down more based on what you said about the 101 field limit). On of the tables
have 256 fields and the other has 186 fields. I'm creating a app to replace
medical type forms.
I'm currently using the command object with the stored procs and it works,
it just ALOT of typing (or copy paste). I did write a little app to create
the stored procs and the base Save/Update vb functions based on whats in the
database, but I still have alot to code.
I will try it again, but if I recall, When I did try the bound controls, I
did have it setup with the dataadapter/command objects and setup a datatable
with relations. Maybe that was what caused my problems, can't remember for
sure (been a few months ago). I'll take another look and see if I can get it
to work.
Thanks again for the reply and any suggestion.
Michael

"Cor Ligthert [MVP]" wrote:
Michael,

I hope that the 120 fields are not in one database table. All wizards in
visual Studio do only work for tables with less than 101 fields.

Otherwise generating a strongly typed dataset in a windowform project will
give you all the commands you need. You can than port them to your SP with
copy and paste.

They are created in the dataset.designe r.vb

(If a table is more than 100 you can use only 100 and than add the one which
exceed those).

A command is named in the dataadapter by the commands as there are
updatecommand.c ommandtype = commandtype.sto redprocedure
updatecommand.c ommandtext = (name of your stored procedure)

http://msdn.microsoft.com/library/de...mmandtopic.asp

http://msdn.microsoft.com/library/de...mberstopic.asp

By the way in fact is there a special newsgroup for this kind of questions.

microsoft.publi c.dotnet.framew ork.adonet

I hope this helps,

Cor

Jan 21 '06 #4
Michel,

100 columns limit. Less than 101.

Cor
Jan 21 '06 #5
Hi Cor,
Is there any limits to the SqlCommand object and the addparameters command.
I'm trying to debug a function that calls a stored proc and for some reason I
had one parameter in the proc that VB.NET errors out on. I've made sure that
the paramater type is correct. I've also made sure I have the correct number
of parameters. I get the following error message:
"Procedure 'intake_AddAdmi nNurseAssessmen t2' expects parameter
'@BleedingWho', which was not supplied."
Now, I can remove this parameter from the proc and my vb proc and the
function works just fine. But as soon as I add it back in, I'll get the same
error. Thanks for any info that you can provide.
Michael
"Cor Ligthert [MVP]" wrote:
Michel,

100 columns limit. Less than 101.

Cor

Jan 23 '06 #6
Michael,

I think that you just has to see in the SP "Procedure
'intake_AddAdmi nNurseAssessmen t2' what '@BleedingWho' is.

Be as well aware that parameternames in OleDB says nothing, there the
sequence of the parameter has to be the same as in the sql procedure or SP.

I hope this helps,

Cor

Jan 24 '06 #7

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

Similar topics

7
6221
by: Mark | last post by:
Hello. I am developing an Access 2000 form, and I want to populate a databound list box using a saved query that requires parameters. Is there any way to do this? I tried creating a DAO querydef object and setting the parameters, and then assigned the querydef object to the list box "rowsource" property. This did not work. Thanks -Mark
5
14113
by: clickon | last post by:
This is driving me nuts, it is such a simply thing to do but i cannot for the life of me work out how you are suposed to do it. I want to update the data in DropDownListB based on what is selected in DropDownListA. I am not trying to do anything fancy with AJAX, i am happy to use Post Backs. If it were two controls just on the page then i would simply specify a control parameter for the SelectCommand of the SQLDataSource control which...
2
1259
by: jeremystein | last post by:
When I drop a SqlConnection on the web form designer, it's created in InitializeComponent. I'd like to use this connection in my Page_Load method, but I don't see anywhere that it's opened. Do I need to open it myself? If so, should I close it also, or will I be interfering with databound controls that use it? If I want to use it in PostBack methods should I re-open it, or leave it open in Page_Load? It seems that I would like to...
4
1841
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is logged in, on each and every page, and redirects the user to a login page if s/he's not logged in. The login page will also take care of some standard setup, such as choosing/populating a user profile. I used to use <!-- #include ... --for this,...
3
5424
by: Jeff | last post by:
hey asp.net 2.0 I want to programmatically populate (with data from the database) a label control in a FormView on a webpage. Is it a good idea to put my logic inside the DataBound event of the FormView?
2
1100
by: J | last post by:
I'm a bit new to asp.net and I'm investigating the best approach to this: I have a contact table that includes stuff like Name, address, phone, etc. Because each contact can contain multiple 'product' values, I have a separate product table that has a many-to-one relationship with the contact table. I also have an 'industry' table that also has a many-to-one relationship with the contact table. 1. I would like to have a page that has...
0
2206
by: morathm | last post by:
I have a windows client database management application written in C# that connects to remote web services to do all the heavy work. The thin-client app uses strong typed datasets, all maintained at the web service, with a web reference to those datasets via exposed s on the web service. The client app has a series of windows forms designed to manage particular types of data. For example, there's a manage users form. On each of these...
0
1018
by: Carl G | last post by:
Hi, I have a question: Is any of Microsoft's databinding code / controls of any use in a real-world MVC application? What is the best way to build an MVC application? For example, is a FormView a complete waste? Background:
5
26634
by: nzkks | last post by:
Hi I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Formview controls In a ASP.Net form I have 20 textboxes and 20 dropdownlists(ddl). All ddl(s) are databound and get the data from a single objectdatasource. All textboxes and ddl(s) support null values. Textboxes are for entering numbers and ddl(s) are for selecting the unit (mm, cm, in, m3, oz, qt like these.). I am using the below code to achieve two...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.