Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP logical -> MSSql Bit
Message
From
06/01/2009 10:21:12
 
 
To
06/01/2009 09:52:07
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01371150
Message ID:
01371382
Views:
9
>>Thanks Cetin, I'll take a look at that tomorrow. I was using the syntax:
>>
>>loRs.AddNew(@laFieldNameArray, @laFieldValueArray) and it just wouldn't accept logical values to fill the bit fields.
>>
>>What you have above suggests that I have to add a new record and then field by field, fill in the values one at a time. Kind of like doing individual REPLACEs in VFP instead of a GATHER FROM ARRAY. I was putting that information into arrarys using a loop, and then doing the AddNew as above. It's hard to imagine that doing one field at a time will work while doing it the way I was doing it won't work. Very strange.
>
>Alan,
>No, I meant it would work with .t./.f. or 1/0. You can use either syntax, ie:
>
>
Local loRS As ADODB.Recordset, ;
>  loCon As ADODB.Connection, ;
>  loCmd As ADODB.Command
>
>loCon = Createobject("ADODB.Connection")
>loCmd = Createobject('ADODB.Command')
>loRS  = Createobject("ADODB.RecordSet")
>With loCon
>  .ConnectionString = "provider=sqlncli;server=.\sqlexpress;"+;
>  "trusted_connection=yes;database=northwind"
>  .Open()
>Endwith
>With loCmd
>  .ActiveConnection = loCon
>  .CommandType = 2	&& Table
>  .CommandText = 'products'
>Endwith
>With loRS
>  .CursorType 	= 2		&& ADOPENDYNAMIC
>  .LockType 	= 4		&& ADLOCKBATCHOPTIMISTIC
>  .CursorLocation = 3		&& ADUSECLIENT
>  .ActiveConnection = loCon
>  .Open(loCmd)
>Endwith
>
>LOCAL ARRAY laFields[2], laValues[2]
>laFields[1] = "productName"
>laFields[2] = "discontinued"
>
>laValues[1] = "Added new 1"
>laValues[2] = .T.
>loRS.AddNew(@laFields, @laValues)
>
>laValues[1] = "Added new 2"
>laValues[2] = .F.
>loRS.AddNew(@laFields, @laValues)
>
>laValues[1] = "Added new 3"
>laValues[2] = .T.
>loRS.AddNew(@laFields, @laValues)
>
>loRS.UpdateBatch()
>loRS.Close()
>loCon.Close()
The error you said in a previous reply, can occur for different reasons, but the reason is not .t./.f. or 1/0 usage.
>
>Did you try w/o that value? It is highly probable the addnew is failing for a reason like primary key violation, field X doesn't accept null etc
>
>Cetin

You may be right. I know that if I do it in the command window using only a few fields, the same AddNew(@FieldArray, @ValueArray) seems to work fine even with logicals, so it might well be something else that I just haven't spotted yet.
Previous
Reply
Map
View

Click here to load this message in the networking platform