473,769 Members | 5,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

You cannot add or change a record because a related record is required in table 'lok"

Hi,

Still the same (unsolved problem), but other error now.
I have a detailsview for inserting data, and a dropdownlist which
selectedValue must be used to fill one of the field of the detailsview.
Table 'pc' is related to table 'lok'.

I tried a lot of things, but still without succes. Here are the two methods
i tried with two different errors. It works only when i introduce directly a
value in "DefaultVal ue" (see below)

Thanks for any help
André
1) first method:
asp:SqlDataSour ce ID="SqlDataSour ce1" runat="server" ....
....
InsertCommand=" INSERT INTO [pc] ([na], [ty], [lok]) VALUES (?, ?, @lok)"
OldValuesParame terFormatString ="original_{ 0}"
ProviderName="S ystem.Data.OleD b"
<InsertParamete rs>
<asp:Paramete r Name="na" Type="String" />
<asp:Paramete r Name="ty" Type="String" />
</InsertParameter s>
.....
Code-behind:
Protected Sub DropDownList1_S electedIndexCha nged(ByVal sender As Object,
ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
lok = DropDownList1.S electedValue
SqlDataSource1. InsertParameter s.Add("lok", lokl)
End Sub

This gives: No value given for one or more required parameters
----------------------------------------------------------------------------
-------------------------
2) second method
asp:SqlDataSour ce ID="SqlDataSour ce1" runat="server" ....
....
InsertCommand=" INSERT INTO [pc] ([na], [ty], [lok]) VALUES (?, ?, @lok)"
OldValuesParame terFormatString ="original_{ 0}"
ProviderName="S ystem.Data.OleD b"
<InsertParamete rs>
<asp:Paramete r Name="na" Type="String" />
<asp:Paramete r Name="ty" Type="String" />
<asp:Paramete r Name="lok" Type="String" DefaultValue="< %=lok %>" />
</InsertParameter s>
....

Code-behind:
Protected Sub DropDownList1_S electedIndexCha nged(ByVal sender As Object,
ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
lok = DropDownList1.S electedValue
End Sub

This gives: You cannot add or change a record because a related record is
required in table 'lokl'
which means in fact that the value of the parameter is not passed!

It works when i give directly a value: <asp:Paramete r Name="lok"
Type="String" DefaultValue="1-45" />


Jun 25 '06 #1
0 3572

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

Similar topics

0
4419
by: Dejan M. | last post by:
Please can you help me with this problem: In the next form, when I Add new person who is not registered in the base I had the massage: The Microsoft Jet database engine cannot find a record in the table 'CLAN' with key matching field(s) JMBG. The question is: How to add data for the unregistered visitors in the next fields: JMBG (unique person number);(translation) STATUS;
0
1770
by: William Wisnieski | last post by:
Hello Everyone: I'm having a very strange problem occurring with my Access 2000 database. I call it the "mystery record." Here's the story: I have a query by form that returns a record set in a datasheet. The user double clicks on a row in that datasheet and a main form (pop up) opens bound to a table with a continuous subform bound to a query.
6
3104
by: Paul T. Rong | last post by:
Dear all, Here is my problem: There is a table "products" in my access database, since some of the products are out of date and stopped manufacture, I would like to delete those PRODUCTS from the table, but I was not allowed to do that, because "there are records related with those PRODUCTS in other tables (e.g. in table "ORDER_DETAIL").
4
2072
by: hao | last post by:
Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone know why? thx
5
1478
by: HS1 | last post by:
Hello I have Win application used to add records into a table (called Clients) in an Access database. I use a DataGrid1 to present records in this table and use some TextBox(es) to display the details of a selected record.
3
2224
by: domcatanzarite | last post by:
How would one create a button that on click advances the form to the next "non recurring record" as opposed to the next record. The field the button needs to que from has groups of duplicate values. I need it to advance the form to the next group of duplicate values not just the next record.
6
3232
by: Chezza | last post by:
Hi All, Similar to many other posters, I don’t have a lot of experience with access (I'm using access 2003) and know little of VB, although I have picked up a bit while working on this project. Here’s the set up. We receive many “little” shipments of four different versions of something. We combine these into one “big” shipment which we send out to be processed and want a total of each version in the big shipment. Currently I have one...
3
2484
gcoaster
by: gcoaster | last post by:
Hello! I am having problem with DLookup Function DLookup looks on form, and finds the combobox = cboFullName and then compares it to the column clientID in tblCLIENTS table. if they match, email is put in text box on form named clientEmail and the control source for that field is linked to a table tblCALLS and clientEmail column. Not sure if DLookup is right for this.. anyways, here is the Code
4
3119
by: PW | last post by:
Hi, I set up a relationship between two tables with the itineraryid fields in both tables: tblDailyItinerary tblDailyMeals I have a form that writes a record to tblDailyItinerary that updates the autonumber field itineraryid. I then bring up a subform which
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10049
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...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3964
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
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.