ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Using Sequence.Nextval in PostgreSQL<p>hi,</p> <p>im new to postgreSQL,</p> <p>how to write insert query with sequence.nextval,</p> <p>i wrote query like below,</p> <p>sql=insert into abc(id,name) value&nbsp; (nextval('sequencename'),'"+txt.text+"');</p> <p>but, getting an error like 'Relation doesn't exist'</p>http://www.aspforums.net/Threads/157850/Using-SequenceNextval-in-PostgreSQL/http://www.aspforums.net/Threads/157850/Using-SequenceNextval-in-PostgreSQL/Tue, 17 Oct 2017 00:32:54 GMTUsing any front end tool develop a web application involving minimum 24 tables.<p>Sir I am new to database and programming. I have a mini project. The aim is to develop a web application and connect it to database with minimum 2-4 tables. I would like to do this project in ASP.Net. Please help me.</p>http://www.aspforums.net/Threads/124626/Using-any-front-end-tool-develop-a-web-application-involving-minimum-24-tables/http://www.aspforums.net/Threads/124626/Using-any-front-end-tool-develop-a-web-application-involving-minimum-24-tables/Sat, 14 Sep 2013 00:55:24 GMTSytax error while using ToDate function in Oracle in C#<p class="post-level">&nbsp;</p> <div class="post-rating " title="0 Points"><span class="detail"><span style="font-size: x-large;">I am writing a query to connect oracle db with asp.net, and i have created a webpage and then i kept&nbsp;6 textboxes, and two buttons for getting input and o/p, on the button click i kept all the thigns, to&nbsp;insert data into db using text boxes. and in textboxes i have to give the date and in oracle db i have created column for those dates, am using to_date function, but i dont know how to write the to_date for continuesly, its says some syntax error. so can you please tell me how to use the to_date function continuesly and next to some appended textboxes, herewith i have written the example query now which i have written and getting error.</span></span></div> <div class="post-rating " title="0 Points">&nbsp;</div> <div class="post-rating " title="0 Points"><span class="detail"><span style="font-size: x-large;">string<span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> oocdate = txtoocaccpteddate.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> filingdate = txtfillingdate.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> fieldautorities = txtfieldwithauth.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> receipt = txtreceiptdate.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> approved = txtapproveddate.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> appvalidfrom = txtapplicationvalidfrom.Text; <br /></span></span><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> appvalidto = txtapplicationvalidto.Text;</span></span><br /><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><br /></span></span><strong><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;"><span style="font-family: Consolas; color: #0000ff; font-size: small;">string</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> sql = </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"insert into&nbsp;tmp (REC_KEY,APPL_NO,EMP_NO,CASE_VISA_TYPE_CODE,CASE_VISA_SUBTYPE_CODE,OOC_ACCEPTED_DATE,FILING_SENT_DATE,FILED_WITH_AUTHORITIES,RECEIPT_DATE,APPROVED_DATE,APPL_VALID_FROM,APPL_VALID_TO)values ('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtreckey.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtrefappno.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtempid.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"',</span></span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">'"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtcasevisatype.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtcasevisatypecode.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + oocdate + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + filingdate + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + fieldautorities + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + txtreceiptno.Text + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + receipt + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + approved + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + appvalidfrom + </span></span><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;"><span style="font-family: Consolas; color: #a31515; font-size: small;">"','DD-MM-YY HH:MI A.M.'))','(TO_DATE('"</span></span></span><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"> + appvalidto + </span></span><span style="color: #a31515;"><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;"><span style="font-family: Consolas; font-size: small;">"','DD-MM-YY HH:MI A.M.'))";<br /><br /></span></span></span><span style="font-family: Consolas; color: #008000; font-size: small;"><span style="font-family: Consolas; color: #008000; font-size: small;"><span style="font-family: Consolas; color: #008000; font-size: small;">// here i have diclared the textboxes as some var name and i have appending them in to_date functions. here first two columns are varchar type, like rec_key and emp id, case visa type, case visa subtype, these things are varchar and other than this everything is date. i dont knnow the syntax for continuesly using to_date function.</span></span></span></span></strong></span></span></div>http://www.aspforums.net/Threads/194398/Sytax-error-while-using-ToDate-function-in-Oracle-in-C/http://www.aspforums.net/Threads/194398/Sytax-error-while-using-ToDate-function-in-Oracle-in-C/Mon, 05 Aug 2013 02:13:59 GMTSave Insert DataTable Rows in Oracle DataBase using C# and ASP.Net<p>how do i store &nbsp;data contained in datatable to database table</p>http://www.aspforums.net/Threads/581332/Save-Insert-DataTable-Rows-in-Oracle-DataBase-using-C-and-ASPNet/http://www.aspforums.net/Threads/581332/Save-Insert-DataTable-Rows-in-Oracle-DataBase-using-C-and-ASPNet/Tue, 19 Feb 2013 04:24:52 GMTSave and Insert Image to database in Windows Forms Application using C#<p>Dear Sir,</p> <p>&nbsp;</p> <p>I am looking for how to insert image in sql server data type Image in the same table I also want to insert Date, Text, Decimal Number using C# windows form.</p> <p>ID int Unchecked<br />Description text Checked<br />Image varchar(50) Checked<br />Picture image Checked<br />Location varchar(50) Checked<br />EntryDate date Checked</p> <p>Thanks &amp; Regards,</p> <p>Shrawan</p>http://www.aspforums.net/Threads/214706/Save-and-Insert-Image-to-database-in-Windows-Forms-Application-using-C/http://www.aspforums.net/Threads/214706/Save-and-Insert-Image-to-database-in-Windows-Forms-Application-using-C/Mon, 25 Feb 2013 06:28:51 GMTOracle ODP.Net Tutorial for ASP.Net<p>Dear Mudassar bhai,</p> <p>Please provide tutorial on ODP.NET.</p>http://www.aspforums.net/Threads/164419/Oracle-ODPNet-Tutorial-for-ASPNet/http://www.aspforums.net/Threads/164419/Oracle-ODPNet-Tutorial-for-ASPNet/Sun, 03 May 2015 03:09:13 GMThow to insert and retrieve data BLOB Column in Oracle database using ASP.Net<p>can someone help me to insert and retrieve photo using blob datatype in oracle table usign asp.net c#</p>http://www.aspforums.net/Threads/107118/how-to-insert-and-retrieve-data-BLOB-Column-in-Oracle-database-using-ASPNet/http://www.aspforums.net/Threads/107118/how-to-insert-and-retrieve-data-BLOB-Column-in-Oracle-database-using-ASPNet/Thu, 02 Jan 2014 01:46:57 GMTHow to find compilation errors for procedure inside Package in Oracle Database<p>Hi</p> <p>I am created a package with the procedure.</p> <p>When i tried to compile the package and package body, it leaves error saying Pakage compiled with errors.</p> <p>But i cant able to see the errors.</p> <p>Can any one give me an idea about how to get the list of errors for the particular package and for the particular procedure.</p> <p>Hope this is clear.</p> <p>Please let me know if this is not.</p> <p>thanks.</p>http://www.aspforums.net/Threads/161050/How-to-find-compilation-errors-for-procedure-inside-Package-in-Oracle-Database/http://www.aspforums.net/Threads/161050/How-to-find-compilation-errors-for-procedure-inside-Package-in-Oracle-Database/Wed, 12 Jun 2013 08:44:22 GMTHow to do custom paging in Oracle Stored Procedure<p>how can create this store proc in oracle thanks;)</p> <p>&nbsp;</p> <div><span>CREATE</span><span>&nbsp;<span>PROCEDURE</span>&nbsp;<span>[dbo]</span><span>.</span><span>[GetCustomersPageWise]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>@PageIndex</span>&nbsp;<span>INT</span>&nbsp;<span>=</span>&nbsp;1</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>@PageSize</span>&nbsp;<span>INT</span>&nbsp;<span>=</span>&nbsp;10</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>@PageCount</span>&nbsp;<span>INT</span>&nbsp;<span>OUTPUT</span></span></div> <div><span>AS</span></div> <div><span>BEGIN</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>SET</span>&nbsp;<span>NOCOUNT</span>&nbsp;<span>ON</span><span>;</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>SELECT</span>&nbsp;<span>ROW_NUMBER</span><span>()</span>&nbsp;<span>OVER</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span>(</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>ORDER</span>&nbsp;<span>BY</span>&nbsp;<span>[CustomerID]</span>&nbsp;<span>ASC</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>)</span><span>AS</span>&nbsp;<span>RowNumber</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[CustomerID]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[CompanyName]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[ContactName]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[City]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[Country]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[PostalCode]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[Phone]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>,</span><span>[Fax]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;<span>INTO</span>&nbsp;<span>#Results</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>FROM</span>&nbsp;<span>[Customers]</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>DECLARE</span>&nbsp;<span>@RecordCount</span>&nbsp;<span>INT</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>SELECT</span>&nbsp;<span>@RecordCount</span>&nbsp;<span>=</span>&nbsp;<span>COUNT</span><span>(*)</span>&nbsp;<span>FROM</span>&nbsp;<span>#Results</span></span></div> <div><span>&nbsp;</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>SET</span>&nbsp;<span>@PageCount</span>&nbsp;<span>=</span>&nbsp;<span>CEILING</span><span>(</span><span>CAST</span><span>(</span><span>@RecordCount</span>&nbsp;<span>AS</span>&nbsp;<span>DECIMAL</span><span>(</span>10<span>,</span>&nbsp;2<span>))</span>&nbsp;<span>/</span>&nbsp;<span>CAST</span><span>(</span><span>@PageSize</span>&nbsp;<span>AS</span>&nbsp;<span>DECIMAL</span><span>(</span>10<span>,</span>&nbsp;2<span>)))</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>PRINT</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>@PageCount</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>SELECT</span>&nbsp;<span>*</span>&nbsp;<span>FROM</span>&nbsp;<span>#Results</span></span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>WHERE</span>&nbsp;<span>RowNumber</span>&nbsp;<span>BETWEEN(</span><span>@PageIndex</span>&nbsp;<span>-</span>1<span>)</span>&nbsp;<span>*</span>&nbsp;<span>@PageSize</span>&nbsp;<span>+</span>&nbsp;1&nbsp;<span>AND(((</span><span>@PageIndex</span>&nbsp;<span>-</span>1<span>)</span>&nbsp;<span>*</span>&nbsp;<span>@PageSize</span>&nbsp;<span>+</span>&nbsp;1<span>)</span>&nbsp;<span>+</span><span>@PageSize</span><span>)</span>&nbsp;<span>-</span>&nbsp;1</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;</span></div> <div><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>DROP</span>&nbsp;<span>TABLE</span>&nbsp;<span>#Results</span></span></div> <div><span>END</span></div> <pre class="brush: sql">CREATE PROCEDURE [dbo].[GetCustomersPageWise] @PageIndex INT = 1 ,@PageSize INT = 10 ,@PageCount INT OUTPUT AS BEGIN SET NOCOUNT ON; SELECT ROW_NUMBER() OVER ( ORDER BY [CustomerID] ASC )AS RowNumber ,[CustomerID] ,[CompanyName] ,[ContactName] ,[City] ,[Country] ,[PostalCode] ,[Phone] ,[Fax] INTO #Results FROM [Customers] DECLARE @RecordCount INT SELECT @RecordCount = COUNT(*) FROM #Results SET @PageCount = CEILING(CAST(@RecordCount AS DECIMAL(10, 2)) / CAST(@PageSize AS DECIMAL(10, 2))) PRINT @PageCount SELECT * FROM #Results WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1 DROP TABLE #Results END</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/174498/How-to-do-custom-paging-in-Oracle-Stored-Procedure/http://www.aspforums.net/Threads/174498/How-to-do-custom-paging-in-Oracle-Stored-Procedure/Thu, 25 Apr 2013 06:22:41 GMTHow to create an AutoIncrement Integer Field in Oracle Database<p>Hi</p> <p>I want to set the auto increment&nbsp;for serial number ,</p> <p>and i how can i call that auto increment in vb.net</p> <p>Can anyone one pls refer any example for my problem ,</p> <p>Thanks in advance.</p>http://www.aspforums.net/Threads/137754/How-to-create-an-AutoIncrement-Integer-Field-in-Oracle-Database/http://www.aspforums.net/Threads/137754/How-to-create-an-AutoIncrement-Integer-Field-in-Oracle-Database/Tue, 14 May 2013 00:20:12 GMTHow to create a package and procedure in oracle database<p>Hi</p> <p>Im new for oracle , i want to know how to create a package and procedure in oracle</p> <p>can anyone&nbsp;sugges any reference to me</p> <p>Thanks in advance&nbsp;</p>http://www.aspforums.net/Threads/162871/How-to-create-a-package-and-procedure-in-oracle-database/http://www.aspforums.net/Threads/162871/How-to-create-a-package-and-procedure-in-oracle-database/Sat, 20 Apr 2013 05:11:52 GMTDifference between Oracle 10 and 11g<p>Please show me the&nbsp;Differenc between Oracle 10 and 11g...</p>http://www.aspforums.net/Threads/402032/Difference-between-Oracle-10-and-11g/http://www.aspforums.net/Threads/402032/Difference-between-Oracle-10-and-11g/Tue, 12 Nov 2013 03:55:58 GMTCan not insert new record to database in the related table<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Just for test purposes I am trying to get the below code to work and using a foreign key constarint in my database, I have an Owners table related to a pets table "1 to many", and in the example below am trying to add the related table of pets but I&nbsp;get the error stated, I would appreciate some help please on what the issue is as I am new to databases, thanks</p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OwnersPetsEntities context = new OwnersPetsEntities();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pet tmpPet = new Pet();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Owner tmpOwner = new Owner();</p> <p>&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpOwner.Id = 1;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpOwner.Name = "John";</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpOwner.Tel = "1234";</p> <p>&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpPet.Id = 1;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpPet.OwnersId = 1;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpPet.Name = tmpPetName;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpPet.Type = tmpPetType;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tmpPet.Colour = tmpPetColour;</p> <p>&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.Owners.Add(tmpOwner);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "It goes past this part as ok"</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.SaveChanges();</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.Pets.Add(tmpPet);</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; context.SaveChanges();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Error:- Message=The INSERT &nbsp;&nbsp;&nbsp;statement conflicted with the FOREIGN KEY constraint "Relationship". The conflict occurred in database"</p> <p>&nbsp;&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/153016/Can-not-insert-new-record-to-database-in-the-related-table/http://www.aspforums.net/Threads/153016/Can-not-insert-new-record-to-database-in-the-related-table/Mon, 16 Dec 2013 22:08:56 GMT