Hi all,
I have a web app that needs to insert into a table. This table has a field that is of numeric data type and it's set to auto-increment. It does not allow nulls. This field is called 'Ev_ID'. It is also the primary key. When I insert using query analyzer with the following sql statement (leaving it up to SQL Server to automatically insert into the Ev_ID field):
INSERT INTO Reg_Event(Ev_Name, Ev_Desc, Ev_Loc, Ev_MaxSlots, Ev_Presenter, Ev_Active) Values ('Testing', 'Testing', etc...etc...)
It works fine. But when I try to do it through the web app, I get the following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'Ev_ID', table 'innovation.dbo.Reg_Event'; column does not allow nulls. INSERT fails.
The code for the SQL string is as follows:
if (Request.form("new_process"
== "Y" ) {
strSql = " INSERT INTO Reg_Event(Ev_Name, Ev_Desc, Ev_Loc, Ev_MaxSlots, Ev_Presenter, Ev_Active)";
strSql+= " VALUES('"+strName+"','"+strDesc+"', '"+strLoc+"','"+numSlots+"', '"+strPres+"', '"+strAct+"') ";
again, leaving it up to SQL Server to insert into Ev_ID.
What could be the problem???!
I have a web app that needs to insert into a table. This table has a field that is of numeric data type and it's set to auto-increment. It does not allow nulls. This field is called 'Ev_ID'. It is also the primary key. When I insert using query analyzer with the following sql statement (leaving it up to SQL Server to automatically insert into the Ev_ID field):
INSERT INTO Reg_Event(Ev_Name, Ev_Desc, Ev_Loc, Ev_MaxSlots, Ev_Presenter, Ev_Active) Values ('Testing', 'Testing', etc...etc...)
It works fine. But when I try to do it through the web app, I get the following error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot insert the value NULL into column 'Ev_ID', table 'innovation.dbo.Reg_Event'; column does not allow nulls. INSERT fails.
The code for the SQL string is as follows:
if (Request.form("new_process"
strSql = " INSERT INTO Reg_Event(Ev_Name, Ev_Desc, Ev_Loc, Ev_MaxSlots, Ev_Presenter, Ev_Active)";
strSql+= " VALUES('"+strName+"','"+strDesc+"', '"+strLoc+"','"+numSlots+"', '"+strPres+"', '"+strAct+"') ";
again, leaving it up to SQL Server to insert into Ev_ID.
What could be the problem???!