Search Results

Search found 30236 results on 1210 pages for 'insert update'.

Page 10/1210 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • SQL query INSERT not working inserting values into my DB.

    - by Aiden Ryan
    Hello, I'm trying to insert registration data into a database but my php code isn't inserting the values into the DB although I'm not getting any errors either, can someone help me? this is the code i'm currently using: $connect = mysql_connect("localhost","myusername","mypassword"); mysql_select_db("application"); $queryreg = mysql_query('INSERT INTO users("username","password","email","date") VALUES("$username","$password","$email","$date")'); die ("You Have Been Registered."); I just need to add the username password email and date into the fields i have specified but it won't work, please someone help!

    Read the article

  • ASP.NET/VB/SQL: trying to insert data, getting error "no value given for required parameters"

    - by Sara
    I am pretty sure this is a basic syntax error, I am new at this and basically figuring things out by trial and error... I am trying to insert data from textboxes into an Access database, where the primary key fields in tableCourse are prefix and course_number. It keeps giving me the "no value given for one or more required parameters" error. Here is my codebehind: Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick 'Collect Data Dim myDept = txtDept.Text Dim myFirst = txtFirstName.Text Dim myLast = txtLastName.Text Dim myPrefix = txtCoursePrefix.Text Dim myNum = txtCourseNum.Text 'Define Connection Dim myConn As New OleDbConnection myConn.ConnectionString = AccessDataSource1.ConnectionString 'Create commands Dim myIns1 As New OleDbCommand("INSERT INTO tableCourse (department, name_first, name_last, prefix, course_number) VALUES (@myDept, @myFirst, @myLast, @myPrefix, @myNum)", myConn) 'Execute the commands myConn.Open() myIns1.ExecuteNonQuery() End Sub

    Read the article

  • Linked List. Insert integers in order

    - by user69514
    I have a linked list of integers. When I insert a new Node I need to insert it not at the end, but in oder... i.e. 2, 4, 5, 8, 11, 12, 33, 55, 58, 102, etc. I don't think I am inserting it in the correct position. Do see what Im doing wrong? Node newNode = new Node(someInt); Node current = head; for(int i=0; i<count; i++){ if(current == tail && tail.data < someInt){ tail.next = newNode; } if(current.data < someInt && current.next.data >= someInt){ newNode.next = current.next; current.next = newNode; } }

    Read the article

  • Insert date and time into Mysql

    - by Jerry
    Hi..guys I am trying to insert date and time into mysql datetime field. When a user select a date and time, it will generate two POST variables. I have searched internet but still not sure how to do it. My code. //date value is 05/25/2010 //time value is 10:00 $date=$_POST['date']; $time=$_POST['time']; $datetime=$date.$time If I insert $datetime into mysql, the date appears to be 0000-00-00:00:00:00 I appreciate it if anyone could help me about this. Thanks.

    Read the article

  • Generating incremental numeric column values during INSERT SELECT statement

    - by Charles
    I need to copy some data from one table to another in Oracle, while generating incremental values for a numeric column in the new table. This is a once-only exercise with a trivial number of rows (100). I have an adequate solution to this problem but I'm curious to know if there is a more elegant way. I'm doing it with a temporary sequence, like so: CREATE SEQUENCE temp_seq START WITH 1; INSERT INTO new_table (new_col, copied_col1, copied_col2) SELECT temp_seq.NEXTVAL, o.* FROM (SELECT old_col1, old_col2 FROM old_table) o; DROP SEQUENCE temp_seq; Is there way to do with without creating the sequence or any other temporary object? Specifically, can this be done with a self-contained INSERT SELECT statement? There are similar questions, but I believe the specifics of my question are original to SO.

    Read the article

  • What are "Failed to fetch cdrom" errors in Update Manager and how do I fix them? [closed]

    - by gcc
    Possible Duplicate: Failed to download repository information due to missing CDROM Whenever I run update-manager, I am getting the following error: Failed to fetch cdrom://Ubuntu 10.04.2 LTS _Lucid Lynx_ - Release amd64 (20110211.1)/dists/lucid/main/binary-amd64/Packages.gz Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs Failed to fetch cdrom://Ubuntu 10.04.2 LTS _Lucid Lynx_ - Release amd64 (20110211.1)/dists/lucid/restricted/binary-amd64/Packages.gz Please use apt-cdrom to make this CD-ROM recognized by APT. apt-get update cannot be used to add new CD-ROMs Failed to fetch http://ppa.launchpad.net/qwibber-daily/ppa/ubuntu/dists/lucid/main/binary-amd64/Packages.gz 404 Not Found How can I get rid of these errors? What is this error trying to tell me?

    Read the article

  • SQL SERVER – Disabled Index and Update Statistics

    - by pinaldave
    When we try to update the statistics, it throws an error as if the clustered index is disabled. Now let us enable the clustered index only and attempt to update the statistics of the table right after that. Have you ever come across the situation where a conversation never gets over and it continues even though original point of discussion has passed. I am facing the same situation in the case of Disabled Index. Here is the link to original conversations. SQL SERVER – Disable Clustered Index and Data Insert – Reader had a issue here with Disabled Index SQL SERVER – Understanding ALTER INDEX ALL REBUILD with Disabled Clustered Index – Reader asked the effect of Rebuilding Indexes The same reader asked me today – “I understood what the disabled indexes do; what is their effect on statistics. Is it true that even though indexes are disabled, they continue updating the statistics?“ The answer is very interesting: If you have disabled clustered index, you will be not able to update the statistics at all for any index. If you have enabled clustered index and disabled non clustered index when you update the statistics of the table, it automatically updates the statistics of the ALL (disabled and enabled – both) the indexes on the table. If you are not satisfied with the answer, let us go over a simple example. I have written necessary comments in the code itself to have a clear idea. USE tempdb GO -- Drop Table if Exists IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[TableName]') AND type IN (N'U')) DROP TABLE [dbo].[TableName] GO -- Create Table CREATE TABLE [dbo].[TableName]( [ID] [int] NOT NULL, [FirstCol] [varchar](50) NULL ) GO -- Insert Some data INSERT INTO TableName SELECT 1, 'First' UNION ALL SELECT 2, 'Second' UNION ALL SELECT 3, 'Third' UNION ALL SELECT 4, 'Fourth' UNION ALL SELECT 5, 'Five' GO -- Create Clustered Index ALTER TABLE [TableName] ADD CONSTRAINT [PK_TableName] PRIMARY KEY CLUSTERED ([ID] ASC) GO -- Create Nonclustered Index CREATE UNIQUE NONCLUSTERED INDEX [IX_NonClustered_TableName] ON [dbo].[TableName] ([FirstCol] ASC) GO -- Check that all the indexes are enabled SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO Now let us update the statistics of the table and check the statistics update date. -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO Now let us disable the indexes and check if they are disabled using sys.indexes. -- Disable Indexes -- Disable Nonclustered Index ALTER INDEX [IX_NonClustered_TableName] ON [dbo].[TableName] DISABLE GO -- Disable Clustered Index ALTER INDEX [PK_TableName] ON [dbo].[TableName] DISABLE GO -- Check that all the indexes are disabled SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO Let us try to update the statistics of the table. -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO /* -- Above operation should thrown following error Msg 1974, Level 16, State 1, Line 1 Cannot perform the specified operation on table 'TableName' because its clustered index 'PK_TableName' is disabled. */ When we try to update the statistics it throws an error as it clustered index is disabled. Now let us enable the clustered index only and attempt to update the statistics of the table right after that. -- Now let us rebuild clustered index only ALTER INDEX [PK_TableName] ON [dbo].[TableName] REBUILD GO -- Check that all the indexes status SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO We can clearly see that even though the nonclustered index is disabled it is also updated. If you do not need a nonclustered index, I suggest you to drop it as keeping them disabled is an overhead on your system. This is because every time the statistics are updated for system all the statistics for disabled indexesare also updated. -- Clean up DROP TABLE [TableName] GO The complete script is given below for easy reference. USE tempdb GO -- Drop Table if Exists IF EXISTS (SELECT * FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N'[dbo].[TableName]') AND type IN (N'U')) DROP TABLE [dbo].[TableName] GO -- Create Table CREATE TABLE [dbo].[TableName]( [ID] [int] NOT NULL, [FirstCol] [varchar](50) NULL ) GO -- Insert Some data INSERT INTO TableName SELECT 1, 'First' UNION ALL SELECT 2, 'Second' UNION ALL SELECT 3, 'Third' UNION ALL SELECT 4, 'Fourth' UNION ALL SELECT 5, 'Five' GO -- Create Clustered Index ALTER TABLE [TableName] ADD CONSTRAINT [PK_TableName] PRIMARY KEY CLUSTERED ([ID] ASC) GO -- Create Nonclustered Index CREATE UNIQUE NONCLUSTERED INDEX [IX_NonClustered_TableName] ON [dbo].[TableName] ([FirstCol] ASC) GO -- Check that all the indexes are enabled SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO -- Disable Indexes -- Disable Nonclustered Index ALTER INDEX [IX_NonClustered_TableName] ON [dbo].[TableName] DISABLE GO -- Disable Clustered Index ALTER INDEX [PK_TableName] ON [dbo].[TableName] DISABLE GO -- Check that all the indexes are disabled SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO /* -- Above operation should thrown following error Msg 1974, Level 16, State 1, Line 1 Cannot perform the specified operation on table 'TableName' because its clustered index 'PK_TableName' is disabled. */ -- Now let us rebuild clustered index only ALTER INDEX [PK_TableName] ON [dbo].[TableName] REBUILD GO -- Check that all the indexes status SELECT OBJECT_NAME(OBJECT_ID), Name, type_desc, is_disabled FROM sys.indexes WHERE OBJECT_NAME(OBJECT_ID) = 'TableName' GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO -- Update the stats of table UPDATE STATISTICS TableName WITH FULLSCAN GO -- Check Statistics Last Updated Datetime SELECT name AS index_name, STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated FROM sys.indexes WHERE OBJECT_ID = OBJECT_ID('TableName') GO -- Clean up DROP TABLE [TableName] GO Reference: Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, SQL, SQL Authority, SQL Index, SQL Optimization, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology Tagged: SQL Statistics

    Read the article

  • Bulk inserting and updating with Entity Framework (Probably a better alternative?)

    - by Dave
    I have a data set of devices, addresses, and companies that I need to import into our database, with the catch that our database may already include a specific device/address/company that is included in the new data set. If that is the case, I need to update that entry with the new information in the data set, excluding addresses. We check if an exact copy of that address exists, otherwise we make a new entry. My issue is that it is very slow to attempt to grab a device/company in EF and if it exist updated it, otherwise insert it. To fix this I tried to get all the companies, devices, and addresses and insert them into respective hashmaps, and check if the identifier of the new data exists in the hashmap. This hasn't led to any performance increases. I've included my code below. Typically I would do a batch insert, I'm not sure what I would do for a batch update though. Can someone advise a different route? var context = ObjectContextHelper.CurrentObjectContext; var oldDevices = context.Devices; var companies = context.Companies; var addresses = context.Addresses; Dictionary<string, Company> companyMap = new Dictionary<string, Company>(StringComparer.OrdinalIgnoreCase); Dictionary<string, Device> deviceMap = new Dictionary<string, Device>(StringComparer.OrdinalIgnoreCase); Dictionary<string, Address> addressMap = new Dictionary<string, Address>(StringComparer.OrdinalIgnoreCase); foreach (Company c in companies) { if (c.CompanyAccountID != null && !companyMap.ContainsKey(c.CompanyAccountID)) companyMap.Add(c.CompanyAccountID, c); } foreach (Device d in oldDevices) { if (d.SerialNumber != null && !deviceMap.ContainsKey(d.SerialNumber)) deviceMap.Add(d.SerialNumber, d); } foreach (Address a in addresses) { string identifier = GetAddressIdentifier(a); if (!addressMap.ContainsKey(identifier)) addressMap.Add(identifier, a); } foreach (DeviceData.TabsDevice device in devices) { // update a device Company tempCompany; Address tempAddress; Device currentDevice; if (deviceMap.ContainsKey(device.SerialNumber)) //update a device deviceMap.TryGetValue(device.SerialNumber, out currentDevice); else // insert a new device currentDevice = new Device(); currentDevice.SerialNumber = device.SerialNumber; currentDevice.SerialNumberTABS = device.SerialNumberTabs; currentDevice.Model = device.Model; if (device.CustomerAccountID != null && device.CustomerAccountID != "") { companyMap.TryGetValue(device.CustomerAccountID, out tempCompany); currentDevice.CustomerID = tempCompany.CompanyID; currentDevice.CustomerName = tempCompany.CompanyName; } if (companyMap.TryGetValue(device.ServicingDealerAccountID, out tempCompany)) currentDevice.CompanyID = tempCompany.CompanyID; currentDevice.StatusID = 1; currentDevice.Retries = 0; currentDevice.ControllerFamilyID = 1; if (currentDevice.EWBFrontPanelMsgOption == null) // set the Panel option to the default if it isn't set already currentDevice.EWBFrontPanelMsgOption = context.EWBFrontPanelMsgOptions.Where( i => i.OptionDescription.Contains("default")).Single(); // link the device to the existing address as long as it is actually an address if (addressMap.TryGetValue(GetAddressIdentifier(device.address), out tempAddress)) { if (GetAddressIdentifier(device.address) != "") currentDevice.Address = tempAddress; else currentDevice.Address = null; } else // insert a new Address and link the device to it (if not null) { if (GetAddressIdentifier(device.address) == "") currentDevice.Address = null; else { tempAddress = new Address(); tempAddress.Address1 = device.address.Address1; tempAddress.Address2 = device.address.Address2; tempAddress.Address3 = device.address.Address3; tempAddress.Address4 = device.address.Address4; tempAddress.City = device.address.City; tempAddress.Country = device.address.Country; tempAddress.PostalCode = device.address.PostalCode; tempAddress.State = device.address.State; addresses.AddObject(tempAddress); addressMap.Add(GetAddressIdentifier(tempAddress), tempAddress); currentDevice.Address = tempAddress; } } if (!deviceMap.ContainsKey(device.SerialNumber)) // if inserting, add to context { oldDevices.AddObject(currentDevice); deviceMap.Add(device.SerialNumber, currentDevice); } } context.SaveChanges();

    Read the article

  • Windows Update for auto-complete filename in Explorer

    - by Stan
    OS: Windows XP SP3 Seems there is a Windows Update improves Explorer interface, adding auto-complete filename feature in open file dialogue, and when press F2 to rename file, the cursor will at filename(cursor here).txt instead of old way - filename.txt(cursor here). Does anyone know which update should I download? Thanks.

    Read the article

  • My -tpl file won't update!

    - by Kyle Sevenoaks
    Hi, I am running the site at www.euroworker.no, it's a linux server and the site has a backend editor. It's a smarty/php site, and when I try to update a few of the .tpl's (two or three) they don't update. I have tried uploading through FTP and that doesn't work either. I have no knowledge of how servers work or anything, please help? It runs on the livecart system. Thanks!

    Read the article

  • My -tpl file won't update!

    - by Kyle Sevenoaks
    Hi, I am running the site at www.euroworker.no, it's a linux server and the site has a backend editor. It's a smarty/php site, and when I try to update a few of the .tpl's (two or three) they don't update. I have tried uploading through FTP and that doesn't work either. I have no knowledge of how servers work or anything, please help? It runs on the livecart system. Thanks!

    Read the article

  • Update password for scheduled task

    - by UserXIII
    I have a scheduled task that needs to run as a service account. The service account's password resets every 100 days, so I need to update the password for the scheduled task. I cannot figure out how to do this. When I select "Change User or Group" in the scheduled tasks' properties I get no prompt to update the password. This scheduled task will be deployed on Windows Server 2008 R2 and Windows 7.

    Read the article

  • update nokia app installed via ovi

    - by Ryan Fernandes
    I've installed a version of a very handy application (Nokia Battery Monitor 1.1) and was quite pleased to see a v1.2 out recently. The problem is that I cant seem to update this app on my phone via the ovi app; the 'download' link is disabled. Also tried the 'sw update' app, but it reports that all applications are up-to-date. Any idea how do this without installing/reinstalling the app? The phone model is Nokia 5800

    Read the article

  • Getting SQL Syntax Error in INSERT INTO statement in Access 2010

    - by hello123
    I have written the following Insert Into statement in Access 2010 VBA: Private Sub AddBPSSButton_Click() ' CurrentDb.Execute "INSERT INTO TabClearDetail(C_Site) VALUES(" & Me.C_Site & ")" Dim strSQL As String 'MsgBox Me.[Clearance Applying For] 'MsgBox Me.[Contract Applying for] 'MsgBox Me.[C_Site] 'MsgBox Me.[C_SponsorSurname] 'MsgBox Me.[C_SponsorForename] 'MsgBox Me.[C_SponsorContactDetails] 'MsgBox Me.[C_EmploymentDetail] 'MsgBox Me.[C_SGNumber] 'MsgBox Me.[C_REF1DateRecd] 'MsgBox Me.[C_REF2DateRecd] 'MsgBox Me.[C_IDDateRecd] 'MsgBox Me.[C_IDNum] 'MsgBox Me.[C_CriminalDeclarationDate] 'MsgBox Me.[Credit Check Consent] 'MsgBox Me.[C_CreditCheckDate] 'MsgBox Me.[Referred for Management Decision] 'MsgBox Me.[Management Decision Date] 'MsgBox Me.[C_Comment] 'MsgBox Me.[C_DateCleared] 'MsgBox Me.[C_ClearanceLevel] 'MsgBox Me.[C_ContractAssigned] 'MsgBox Me.[C_ExpiryDate] 'MsgBox Me.[C_LinKRef] 'MsgBox Me.[C_OfficialSecretsDate] strSQL = "INSERT INTO TabClearDetail(Clearance Applying For, Contract Applying for, " & _ "C_Site, C_SponsorSurname, C_SponsorForename, C_SponsorContactDetails, C_EmploymentDetail, " & _ "C_SGNumber, C_REF1DateRecd, C_RED2DateRecd, C_IDDateRecd, C_IDNum, " & _ "C_CriminalDeclarationDate, Credit Check Consent, C_CreditCheckDate, Referred for Management Decision, " & _ "Management Decision Date, C_Comment, C_DateCleared, C_ClearanceLevel, C_ContractAssigned, " & _ "C_ExpiryDate, C_LinkRef, C_OfficialSecretsDate) VALUES('" & Me.[Clearance Applying For] & "', " & _ "'" & Me.[Contract Applying for] & "', '" & Me.[C_Site] & "', '" & Me.[C_SponsorSurname] & "', " & _ "'" & Me.[C_SponsorForename] & "', '" & Me.[C_SponsorContactDetails] & "', " & _ "'" & Me.[C_EmploymentDetail] & "', '" & Me.[C_SGNumber] & "', '" & Me.[C_REF1DateRecd] & "', " & _ "'" & Me.[C_REF2DateRecd] & "', '" & Me.[C_IDDateRecd] & "', '" & Me.[C_IDNum] & "', " & _ "'" & Me.[C_CriminalDeclarationDate] & "', '" & Me.[Credit Check Consent] & "', '" & Me.[C_CreditCheckDate] & "', " & _ "'" & Me.[Referred for Management Decision] & "', '" & Me.[Management Decision Date] & "', " & _ "'" & Me.[C_Comment] & "', '" & Me.[C_DateCleared] & "', '" & Me.[C_ClearanceLevel] & "', " & _ "'" & Me.[C_ContractAssigned] & "', '" & Me.[C_ExpiryDate] & "', '" & Me.[C_LinKRef] & "', " & _ "'" & Me.[C_OfficialSecretsDate] & "');" DoCmd.RunSQL (strSQL) 'MsgBox strSQL End Sub All The MsgBox calls work, so I believe I have typed all column names and text box names correctly. I am getting a Syntax error when I get to the DoCmd.RunSQL line. Have been staring at this for quite a while trying to see if I have missed a comma or speech mark or something, but am hoping maybe another set of eyes will see my mistake. Any help will be greatly appreciated. Thanks!

    Read the article

  • inserting data into mysql

    - by francesco
    Hi Guys, My insert and update pages (through my admin forlder) into mysql stopped working. When I try to insert/update details it stays on the same page without adding or updating anything into the database table. I really don't know what happened and don't know where start looking. I didn't make any change to the pages whatsoever. Is there anyone who had the same problem and can kindly give me a clue? Appreciated Francesco

    Read the article

  • how to insert multiple rows using cakephp

    - by Paul
    In the cakePHP project I'm building, I want to insert a defined number of identical records. These will serve as placeholders records that will have additional data added later. Each record will insert the IDs taken from two belongs_to relationships as well as two other string values. What I want to do is be able to enter a value for the number of records I want created, which would equate to how many times the data is looped during save. What I don't know is: 1) how to setup a loop to handle a set number of inserts 2) how to define a form field in cakePHP that only sets the number of records to create. What I've tried is the following: function massAdd() { $inserts_required = 1; while ($inserts_required <= 10) { $this->Match->create(); $this->Match->save($this->data); echo $inserts_required++; } $brackets = $this->Match->Bracket->find('list'); $this->set(compact('brackets')); } What happens is: 1) at the top of the screen, above the doc type, the string 12345678910 is displayed, this is displayed on screen 2) a total of 11 records are created, and only the last record has the values passed in the form. I don't know why 11 records as opposed to 10 are created, and why only the last records has the entered form data? As always, your help and direction is appreciated. -Paul

    Read the article

  • [EF 4 POCO] Problem with INSERT...

    - by Darmak
    Hi all, I'm so frustrated because of this problem, you have no idea... I have 2 classes: Post and Comment. I use EF 4 POCO support, I don't have foreign key columns in my .edmx model (Comment class doesn't have PostID property, but has Post property) class Comment { public Post post { get; set; } // ... } class Post { public virtual ICollection<Comment> Comments { get; set; } // ... } Can someone tell me why the code below doesn't work? I want to create a new comment for a post: Comment comm = context.CreateObject<Comment>(); Post post = context.Posts.Where(p => p.Slug == "something").SingleOrDefault(); // post != null, so don't worry, be happy // here I set all other comm properties and... comm.Post = post; context.AddObject("Comments", comm); // Exception here context.SaveChanges(); The Exception is: Cannot insert the value NULL into column 'PostID', table 'Blog.Comments'; column does not allow nulls. INSERT fails. ... this 'PostID' column is of course a foreign key to the Posts table. Any help will be appreciated!

    Read the article

  • Increment non unique field during SQL insert

    - by phill
    I'm not sure how to word this cause I am a little confused at the moment, so bare with me while I attempt to explain, I have a table with the following fields: OrderLineID, OrderID, OrderLine, and a few other unimportant ones. OrderLineID is the primary key and is always unique(which isn't a problem), OrderID is a foreign key that isn't unique(also not a problem), and OrderLine is a value that is not unique in the table, but should be unique for any OrderIDs that are the same...so if that didn't make sense, perhaps a picture OrderLineID, OrderID, OrderLine 1 1 1 2 1 2 3 1 3 4 2 1 5 2 2 For all OrderIDs there is a unique OrderLine. I am trying to create an insert statement that gets the max OrderLine value for a specific OrderId so I can increment it, but it's not working so well and I could use a little help. What I have right now is below, I build the sql statement in a program and replace OrderID # with an actual value. I am pretty sure the problem is with the nested select statement, and incrementing the result, but I can't find any examples that do this since my google skills are weak apparently.... INSERT INTO tblOrderLine (OrderID, OrderLine) VALUES (<OrderID #>, (SELECT MAX(OrderLine) FROM tblOrderLine WHERE orderID = <same OrderID #>)+1) any help would be nice.

    Read the article

  • insert Query is not executing, help me in tracking the problem

    - by Parth
    I tried the below query but it didnt executed giving error as : 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 INSERT INTO `jos_menu` SET params = 'orderby= show_noauth= show_title= link_titles= show_intro= show_section= link_section= show_category= link_category= show_author= show_create_date= show_modify_date= show_item_navigation= show_readmore= show_vote= show_icons= show_pdf_icon= show_print_icon= show_email_icon= show_hits= feed_summary= page_title= show_page_title=1 pageclass_sfx= menu_image=-1 secure=0 ', checked_out_time = '0000-00-00 00:00:00', ordering = '13', componentid = '20', published = '1', id = '152', menutype = 'accmenu', name = 'IPL', alias = 'ipl', link = 'index.php?option=com_content&view=archive', type = 'component') then i used mysql_real_escape_string() on the query containing variable which gives me the query as : INSERT INTO `jos_menu` SET params = \'orderby=\nshow_noauth=\nshow_title=\nlink_titles=\nshow_intro=\nshow_section=\nlink_section=\nshow_category=\nlink_category=\nshow_author=\nshow_create_date=\nshow_modify_date=\nshow_item_navigation=\nshow_readmore=\nshow_vote=\nshow_icons=\nshow_pdf_icon=\nshow_print_icon=\nshow_email_icon=\nshow_hits=\nfeed_summary=\npage_title=\nshow_page_title=1\npageclass_sfx=\nmenu_image=-1\nsecure=0\n\n\', checked_out_time = \'0000-00-00 00:00:00\', ordering = \'13\', componentid = \'20\', published = \'1\', id = \'152\', menutype = \'accmenu\', name = \'IPL\', alias = \'ipl\', link = \'index.php?option=com_content&view=archive\', type = \'component\') And on executing the above query I get an error as : 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\'orderby=\nshow_noauth=\nshow_title=\nlink_titles=\nshow_intro=\nshow_section=\' at line 1 Can Someone guide me to track the problem in it? Thanks In Advance....

    Read the article

  • Insert array to mysql database php

    - by ganjan
    Hi. I want to add an array to my db. I have set up a function that checks if a value in the db (ex. health and money) has changed. If the value is diffrent from the original I add the new value to the $db array. Like this $db['money'] = $money_input + $money_db;. function modify_user_info($conn, $money_input, $health_input){ (...) if ($result = $conn->query($query)) { while ($user = $result->fetch_assoc()) { $money_db = $user["money"]; $health_db = $user["health"]; } $result->close(); //lag array til db med kolonnene som skal fylles ut som keys i array if ($user["money"] != $money_input){ $db['money'] = $money_input + $money_db; //0 - 20 if (!preg_match("/^[[0-9]{0,20}$/i", $db['money'])){ echo "error"; return false; } } if ($user["health"] != $health_input){ $db['health'] = $health_input + $health_db; //0 - 4 if (!preg_match("/^[[0-9]{0,4}$/i", $db['health'])){ echo "error"; return false; } if (($db['health'] < 1) or ($db['health'] > 1000)) { echo "error"; return false; } } The keys in $db represent colums in my database. Now I want to make a function that takes the keys in the array $db and insert them in the db. Something like this ? $query = "INSERT INTO `main_log` ( `id` , "; foreach(range(0, x) as $num) { $query .= array_key.", "; } $query = substr($query, 0, -3); $query .= " VALUES ('', "; foreach(range(0, x) as $num) { $query .= array_value.", "; } $query = substr($query, 0, -3); $query .= ")";

    Read the article

  • Insert Stored Procedure, Using Asp.Net WebForm to Insert new [Customer]

    - by user2953815
    Can someone please help me create a stored procedure to insert a new customer from a web form. I am having difficulty making the state a drop down list for customer to pick a state from the list and having that inserted into the database. INSERT INTO Customer ( Cust_First, Cust_Middle, Cust_Last, Cust_Phone, Cust_Alt_Phone, Cust_Email, Add_Line1, Add_Line2, Add_Bill_Line1, Add_Bill_Line2, City, State_Prov_Name, Postal_Zip_Code, Country_ID ) VALUES ( @Cust_First, @Cust_Middle, @Cust_Last, @Cust_Phone, @Cust_Alt_Phone, @Cust_Email, @Add_Line1, @Add_Line2, @Add_Bill_Line1, @Add_Bill_Line2, @City, @State_Prov_Name, @Postal_Zip_Code, @Country_ID )"> <InsertParameters> <asp:Parameter Name="Cust_First" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_Middle" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_Last" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_Phone" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_Alt_Phone" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_Email" Type="String"></asp:Parameter> <asp:Parameter Name="Add_Line1" Type="String"></asp:Parameter> <asp:Parameter Name="Add_Line2" Type="String"></asp:Parameter> <asp:Parameter Name="Add_Bill_Line1" Type="String"></asp:Parameter> <asp:Parameter Name="Add_Bill_Line2" Type="String"></asp:Parameter> <asp:Parameter Name="City" Type="String"></asp:Parameter> <asp:Parameter Name="Postal_Zip_Code" Type="String"></asp:Parameter> <asp:Parameter Name="Cust_ID" Type="Int32"></asp:Parameter> <asp:Parameter Name="State_Prov_Name" Type="String"></asp:Parameter> <asp:Parameter Name="Country_Name" Type="String"></asp:Parameter> </InsertParameters>

    Read the article

  • [C#] Linq doesn't insert associated entity on insert.

    - by Tomek
    Hello! I have simple mapping: [Table(Name="Person")] public class Person { private int id; private int state_id; private EntityRef<PersonState> state = new EntityRef<PersonState>(); [Column(IsPrimaryKey = true, Storage = "id", Name="id", IsDbGenerated = true, CanBeNull = false)] public int ID { get { return id; } set { id = value; } } [Column(Storage="state_id", Name="state_id")] public int StateID { get{ return state_id;} set{ state_id = value;} } [Association( Storage = "state", ThisKey = "StateID", IsForeignKey=true)] public PersonState State { get { return state.Entity; } set { state.Entity = value; } } } [Table(Name = "PersonState")] public class PersonState { private int id; private State state; [Column(Name="id", Storage="id", IsDbGenerated=true, IsPrimaryKey=true)] public int ID { get { return id; } set { id = value; } } [Column(Name = "date", Storage = "date")] public DateTime Date { get { return date; } set { date = value; } } [Column(Name = "type", Storage = "state")] public State State { get { return state; } set { state = value; } } } I use this code to insert new person with default state: private static Person NewPerson() { Person p = new Person(); p.State = DefaultState(p); return p; } private static PersonState DefaultState() { PersonState state = new PersonState(); state.Date = DateTime.Now; state.State = State.NotNotified; state.Comment = "Default State!"; return state; } Leater in code: db.Persons.InsertOnSubmit(NewPerson()); db.SubmitChanges(); In database(sqlite) I have all new persons, but state_id of all persons is set to 0, and PersonState table is empty. Why Linq did not insert any State object to database?

    Read the article

  • Trying to Insert Text to Access Database with ExecuteNonQueryin VB

    - by user3673701
    I'm working on this feature were i save text from a textbox on my form to a access database file. With the click on my "store" button I want to save the text in the corresponding textbox fields to the fields in my access database for searching and retrieving purposes. Im doing this in VB The problem I run into is the INSERT TO error with my "store" button Any help or insight as to why im getting error would be greatly appreciated. here is my code: Dim con As System.Data.OleDb.OleDbConnection Dim cmd As System.Data.OleDb.OleDbCommand Dim dr As System.Data.OleDb.OleDbDataReader Dim sqlStr As String Private Sub btnStore_Click(sender As Object, e As EventArgs) Handles btnStore.Click con = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Eric\Documents\SPC1.2.accdb") con.Open() MsgBox("Initialized") sqlStr = "INSERT INTO Master FADV Calll info (First Name, Last Name, Phone Number, Email, User Id) values (" & txtFirstName.Text & " ' ,'" & txtLastName.Text & "','" & txtPhone.Text & "', '" & txtEmail.Text & "', '" & txtUserID.Text & "', '" & txtOtherOptionTxt.Text & "','" & txtCallDetail.Text & "');" cmd = New OleDb.OleDbCommand(sqlStr, con) cmd.ExecuteNonQuery() <------- **IM RECIVING THE ERROR HERE** MsgBox("Stored") ''pass ther parameter as sq; query, con " connection Obj)" con.Close()'

    Read the article

  • Can the update manager download only a single package at a time?

    - by SaultDon
    I need the update manager to only download a single package at a time and not try to download multiple packages at once. My slow internet cannot handle multiple connections; slows the download to a crawl and some packages will reset themselves halfway through when they time-out. EDIT When using apt-get update multiple repositories get checked: When using apt-get upgrade multiple packages are downloaded:

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >