First of all you need to check your database table schema, if all the columns are null or having any default value specified then only your goal is achieved, means with out entering anything and clicking on button your blank record is created.
here you are using
itemmaster
table, so if its schmea is allowing null value/ default value to columns
itemcode, name, salesprice, salestax,profit, quantityonhand
then you can insert a default value/null value record to your table.
can you please share your table schema, and also don't forget to updated your error details, like what error message you are getting while inserting a blank row.
UPDATES
As you have shared your database table schema as per below script
CREATE TABLE [dbo].[itemmaster](
[itemcode] [int] NOT NULL,
[name] [varchar](50) NULL,
[salesprice] [decimal](18, 0) NULL,
[salestax] [decimal](18, 0) NULL,
[profit] [decimal](18, 0) NULL,
[quantityonhand] [decimal](18, 0) NULL,
PRIMARY KEY CLUSTERED
(
[itemcode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
You have set
itemcode
as primary key with out identity column, so you need to provide value for that column while inserting record. Rest of the columns are allowed null, so you can either specified value for it or not that work to insert the data to your
itemmaster
table.
Or As per the below script you can modify your table schema and define
itemcode
as Identity Column with Primary Key, then database will automatically increment the next identity value and insert it to your table while inserting the records.
DROP TABLE [dbo].[itemmaster]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[itemmaster](
[itemcode] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NULL,
[salesprice] [decimal](18, 0) NULL,
[salestax] [decimal](18, 0) NULL,
[profit] [decimal](18, 0) NULL,
[quantityonhand] [decimal](18, 0) NULL,
CONSTRAINT [PK__itemmast__986EE407B02D1FB9] PRIMARY KEY CLUSTERED
(
[itemcode] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
Suggesion: please do not use inline query in your application, it will allow
SQL Injection[
^] to be injected to your application.
Instead using inline query use store procedure with in your application like this
Store Procedure Demo[
^]