Ask a Question related to ASP Database, Design and Development.
-
James Bowman #1
Sending null values in SQL statements
I am using an authoring program called Authorware to send
student scores to ASP pages which send SQL INSERT and
UPDATE statements to an Access database. Everything
works well as long as I provide a value for each variable
that places a value in one of the Access database
fields. For both the INSERT and UPDATE statements, I
would like to provide "real" values for some fields and
null values for the others. For example, I would like to
INSERT a new record with strings in some fields and null
values in others. Later, an UPDATE statement may place
values in some of the null fields and place no value in
the other null fields.
I use two ASP pages: one for INSERT and one for UPDATE.
I would like to use one complete SQL statement in each
ASP page that specifies all fields. Then, I would
provide values for some fields and not others. In my
tests, I'm unable to do this. Is there a workaround?
Thanks.
Jim Bowman
James Bowman Guest
-
cfgridupdate and null values
Yeah I have the same problem. It looks like the only solution is to rewrite a custom version cfgridupdate to do my own custom query update. I... -
Null Values
hi how to count null values in an array? tnx -
Detecting Null Values
I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. ... -
Null values enter to SQL
Hi, I have datagrid filled using SqlDataAdapter. One of the fields is a date field which can be null. When I assign null value I receive the... -
Using Field Values in If/Then/Else Statements
I need to know how to use the value of a table field in a If...Then...Else... statement. I'm using an expression to merge data from several fields... -
Bob Lehmann #2
Re: Sending null values in SQL statements
You could write a function that formats the value....
Function FormatDBStr(Field)
If Not Field = "" Then
FormatDBStr = "'" & Field & "'"
Else
FormatDBStr = "NULL"
End If
End Function
sql = "UPDATE table_name SET field_name=" & FormatDBStr(FieldValue) & "
WHERE unique_field =something"
Bob Lehmann
"James Bowman" <james@jbassoc.biz> wrote in message
news:10b7a01c44066$5cba4690$a601280a@phx.gbl...> I am using an authoring program called Authorware to send
> student scores to ASP pages which send SQL INSERT and
> UPDATE statements to an Access database. Everything
> works well as long as I provide a value for each variable
> that places a value in one of the Access database
> fields. For both the INSERT and UPDATE statements, I
> would like to provide "real" values for some fields and
> null values for the others. For example, I would like to
> INSERT a new record with strings in some fields and null
> values in others. Later, an UPDATE statement may place
> values in some of the null fields and place no value in
> the other null fields.
>
> I use two ASP pages: one for INSERT and one for UPDATE.
> I would like to use one complete SQL statement in each
> ASP page that specifies all fields. Then, I would
> provide values for some fields and not others. In my
> tests, I'm unable to do this. Is there a workaround?
>
> Thanks.
>
> Jim Bowman
>
Bob Lehmann Guest
-
James Bowman #3
Re: Sending null values in SQL statements
Thanks Bob. Based on your input, I put this code in the
asp page and it works well:
if myvar="NULL" then
SQL=SQL & "FieldName=NULL,"
else
SQL=SQL & "FieldName='" & myvar & "',"
end if
SQL is the UPDATE statement. The above code is inserted
inside the SQL string.
I note that you use the Function/End Function format. I
used a simple if-then statement. What's the value of the
Function/End Function format in this case?
Thanks.
James
(FieldValue) & ">-----Original Message-----
>You could write a function that formats the value....
>
>Function FormatDBStr(Field)
> If Not Field = "" Then
> FormatDBStr = "'" & Field & "'"
> Else
> FormatDBStr = "NULL"
> End If
> End Function
>
>sql = "UPDATE table_name SET field_name=" & FormatDBStrsend>WHERE unique_field =something"
>
>Bob Lehmann
>
>
>
>"James Bowman" <james@jbassoc.biz> wrote in message
>news:10b7a01c44066$5cba4690$a601280a@phx.gbl...>> I am using an authoring program called Authorware tovariable>> student scores to ASP pages which send SQL INSERT and
>> UPDATE statements to an Access database. Everything
>> works well as long as I provide a value for eachto>> that places a value in one of the Access database
>> fields. For both the INSERT and UPDATE statements, I
>> would like to provide "real" values for some fields and
>> null values for the others. For example, I would likenull>> INSERT a new record with strings in some fields andUPDATE.>> values in others. Later, an UPDATE statement may place
>> values in some of the null fields and place no value in
>> the other null fields.
>>
>> I use two ASP pages: one for INSERT and one for>>> I would like to use one complete SQL statement in each
>> ASP page that specifies all fields. Then, I would
>> provide values for some fields and not others. In my
>> tests, I'm unable to do this. Is there a workaround?
>>
>> Thanks.
>>
>> Jim Bowman
>>
>
>.
>James Bowman Guest
-
Bob Lehmann #4
Re: Sending null values in SQL statements
The function can be reused so you don't have to keep writing the same,
lengthier code over and over.
Bob Lehmann
"James Bowman" <james@jbassoc.biz> wrote in message
news:1222401c44286$d8201a90$a601280a@phx.gbl...> Thanks Bob. Based on your input, I put this code in the
> asp page and it works well:
>
> if myvar="NULL" then
> SQL=SQL & "FieldName=NULL,"
> else
> SQL=SQL & "FieldName='" & myvar & "',"
> end if
>
> SQL is the UPDATE statement. The above code is inserted
> inside the SQL string.
>
> I note that you use the Function/End Function format. I
> used a simple if-then statement. What's the value of the
> Function/End Function format in this case?
>
> Thanks.
>
> James
>> (FieldValue) & "> >-----Original Message-----
> >You could write a function that formats the value....
> >
> >Function FormatDBStr(Field)
> > If Not Field = "" Then
> > FormatDBStr = "'" & Field & "'"
> > Else
> > FormatDBStr = "NULL"
> > End If
> > End Function
> >
> >sql = "UPDATE table_name SET field_name=" & FormatDBStr> send> >WHERE unique_field =something"
> >
> >Bob Lehmann
> >
> >
> >
> >"James Bowman" <james@jbassoc.biz> wrote in message
> >news:10b7a01c44066$5cba4690$a601280a@phx.gbl...> >> I am using an authoring program called Authorware to> variable> >> student scores to ASP pages which send SQL INSERT and
> >> UPDATE statements to an Access database. Everything
> >> works well as long as I provide a value for each> to> >> that places a value in one of the Access database
> >> fields. For both the INSERT and UPDATE statements, I
> >> would like to provide "real" values for some fields and
> >> null values for the others. For example, I would like> null> >> INSERT a new record with strings in some fields and> UPDATE.> >> values in others. Later, an UPDATE statement may place
> >> values in some of the null fields and place no value in
> >> the other null fields.
> >>
> >> I use two ASP pages: one for INSERT and one for> >> >> I would like to use one complete SQL statement in each
> >> ASP page that specifies all fields. Then, I would
> >> provide values for some fields and not others. In my
> >> tests, I'm unable to do this. Is there a workaround?
> >>
> >> Thanks.
> >>
> >> Jim Bowman
> >>
> >
> >.
> >
Bob Lehmann Guest



Reply With Quote

