473,396 Members | 2,010 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,396 software developers and data experts.

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 "DefaultValue" (see below)

Thanks for any help
André
1) first method:
asp:SqlDataSource ID="SqlDataSource1" runat="server" ....
....
InsertCommand="INSERT INTO [pc] ([na], [ty], [lok]) VALUES (?, ?, @lok)"
OldValuesParameterFormatString="original_{0}"
ProviderName="System.Data.OleDb"
<InsertParameters>
<asp:Parameter Name="na" Type="String" />
<asp:Parameter Name="ty" Type="String" />
</InsertParameters>
.....
Code-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
lok = DropDownList1.SelectedValue
SqlDataSource1.InsertParameters.Add("lok", lokl)
End Sub

This gives: No value given for one or more required parameters
----------------------------------------------------------------------------
-------------------------
2) second method
asp:SqlDataSource ID="SqlDataSource1" runat="server" ....
....
InsertCommand="INSERT INTO [pc] ([na], [ty], [lok]) VALUES (?, ?, @lok)"
OldValuesParameterFormatString="original_{0}"
ProviderName="System.Data.OleDb"
<InsertParameters>
<asp:Parameter Name="na" Type="String" />
<asp:Parameter Name="ty" Type="String" />
<asp:Parameter Name="lok" Type="String" DefaultValue="<%=lok %>" />
</InsertParameters>
....

Code-behind:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
lok = DropDownList1.SelectedValue
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:Parameter Name="lok"
Type="String" DefaultValue="1-45" />


Jun 25 '06 #1
0 3553

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

Similar topics

0
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...
0
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...
6
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...
4
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...
5
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...
3
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...
6
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. ...
3
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,...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
0
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,...

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.