I've been asked to code a form for a website. The form contains 40 or so textboxes, so I just wrote some really long INSERT query (if there is a better way, please suggest it) to insert them in. Now, I keep getting "Object reference not set to an instance of an object" on the following code
OleDbCommand theCommand = new OleDbCommand();
theCommand.Connection = theConnection;
theCommand.CommandText = @"INSERT INTO [SQLserverSQL].[dbo].[Records]
([computerName]
,[operatingSystem]
,[serialNumber]
,[hardwareManufacturer]
,[modelType]
,[warrantyExpiration]
,[serverFunction]
,[retailCorporate]
,[dcenterStoreLocation]
,[rackNumber]
,[supportGroup]
,[cellNumber]
,[Product Number]
,[localAdminID]
,[localAdminPW]
,[cpuNumber]
,[cpuType]
,[cpuSpeed]
,[networkAdapters]
,[speedDuplex]
,[primaryIP]
,[secondaryIP]
,[riloName]
,[riloIP]
,[totalMemory]
,[totalDiskSpace]
,[C_OS]
,[D_Data]
,[E_Apps]
,[networkCableID]
,[power]
,[changeWindow]
,[appName]
,[businessOwner]
,[appVendor]
,[appSupportGroup]
,[appFunction]
,[appCode]
,[specialRequirements])
VALUES
(" + computerName.ToString()
+ "," + operatingSystem.SelectedIndex.ToString()
+ "," + serialNumber.ToString()
+ "," + hardwareManufacturer.SelectedIndex.ToString()
+ "," + modelType.SelectedIndex.ToString()
+ "," + warrantyExpiration.ToString()
+ "," + serverFunction.SelectedItem.ToString()
+ "," + retailCorporate.SelectedItem.ToString()
+ "," + dCenterStoreLocation.SelectedItem.ToString()
+ "," + gridLocation.SelectedItem.ToString()
+ "," + supportGrp.ToString()
+ "," + cellPagerNumber.ToString()
+ "," + productNumber.ToString()
+ "," + localAdminID.ToString()
+ "," + localAdminPW.ToString()
+ "," + cpuNumber.SelectedItem.ToString()
+ "," + cpuType.SelectedItem.ToString()
+ "," + cpuSpeed.SelectedItem.ToString()
+ "," + netAdapters.SelectedItem.ToString()
+ "," + speedDuplex.SelectedItem.ToString()
+ "," + primaryIP.ToString()
+ "," + secondaryIP.ToString()
+ "," + riloName.ToString()
+ "," + riloIP.ToString()
+ "," + totalMemory.ToString()
+ "," + totalDiskSpace.ToString()
+ "," + C_OS.SelectedItem.ToString()
+ "," + D_Data.SelectedItem.ToString()
+ "," + E_Apps.SelectedItem.ToString()
+ "," + netCableID.ToString()
+ "," + power.ToString()
+ "," + changeWindow.ToString()
+ "," + appName.ToString()
+ "," + businessOwner.ToString()
+ "," + appVendor.ToString()
+ "," + appSupportGrp.ToString()
+ "," + appFunc.ToString()
+ "," + appCode.ToString()
+ "," + specReq.ToString() + ")";
It occurs on the third line, but I don't know what's causing it, as this is the way I've always done it before. Any ideas?