0

I have the following select statement:

`Dim rsGetInvoiceContact
 Dim rsGetInvoiceContact_numRows

 Set rsGetInvoiceContact = Server.CreateObject("ADODB.Recordset")
 rsGetInvoiceContact.ActiveConnection = MM_conn_to_EFACs_STRING_ap
 rsGetInvoiceContact.Source = "SELECT *   from "& ActinicPersons &" p  WHERE p.[Contact          ID] = " + Replace(rsGetInvoiceContact__vInvoiceID, "'", "''") + "" 
 rsGetInvoiceContact.CursorType = 0
 rsGetInvoiceContact.CursorLocation = 2
 rsGetInvoiceContact.LockType = 1
 rsGetInvoiceContact.Open()

 rsGetInvoiceContact_numRows = 0

 "& FormatStr(rsGetInvoiceContact.Fields.Item("Address Line 1").Value) + ", " +      (rsGetInvoiceContact.Fields.Item("Address Line 2").Value) &"',`

Later on in my script I plus address line 1 with address line 2. The problem occurs when address line 2 has a NULL value. How can I replace that from the select statement so that if only address line 1 has a value, it will still insert into the database rather than leave a blank cell.

Thanks

4

2 に答える 2

0

「whereaddressline2がnullではない」のようなwhere句を追加するか、スクリプトにアドレス行に加えて次のようなものを使用することができます。

adress = (adress1&"") & (adress2&"")

これにより、null値ではなく常に文字列が使用されます

于 2012-06-21T10:06:15.140 に答える
0

MySQL や SqlServer の coalesce() 関数のような null 処理関数を使用できます。

adress = coalesce(adress1,"") & coalesce(adress2,"")

2 番目のパラメーターを予想されるデフォルト値に置き換えることができます。

于 2012-06-21T10:28:43.157 に答える