Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

ADO wildcard?

hi, im having a problem binding data to a crystal report. but actually i think the problem is caused by ADODB from which i get the data.
The problem is, when there are field names with an underscore,
eg: U_ID
ADO doesnt bind it. I use .csv files as data source and use MS VC++ 6.0.
How do i write the Column headers in the .csv file and the Schema.ini file so that ADO doesnt mind the wildcards? :confused:
thnx!
[433 byte] By [Niro1983] at [2007-11-11 8:03:10]
# 1 Re: ADO wildcard?
Are you getting any errors? Could you post a sample of the first several lines of your csv file?
pclement at 2007-11-11 23:47:13 >
# 2 Re: ADO wildcard?
Nope. im not getting any errors. the crystal report just seems to ignore that particular field.

records.csv-->
"U_ID"
"A1"
"A2"
"A3"
"002"
"001"
"NIRO"
"DUMINDA"
"Chaminda"
"Kamal"
//////////////////////////////////////////////////
Schema.ini-->
[records.csv]
ColNameHeader=True
Format=CSVDelimited
MaxScanRows=25
CharacterSet=OEM
Col1="U_ID" Char Width 255

i tried replacing '_' with a space, bt still nothing happens. :SICK:
Niro1983 at 2007-11-11 23:48:21 >
# 3 Re: ADO wildcard?
Is there a reason you need a schema.ini file? I tried the following using your data sample and I didn't experience any problems:

Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim fld As ADODB.Field

cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "C:\Documents and Settings\...\My Documents\My Database\Text;" & _
"Extended Properties=""Text;HDR=YES;FMT=Delimited;"""

rs.Open "Select * from Records.csv", cnn, adOpenStatic, adLockReadOnly

While Not rs.EOF
For Each fld In rs.Fields
Debug.Print fld.Name & " : " & fld.Value & " : " & fld.type
Next fld
rs.MoveNext
Wend

rs.Close
Set rs = Nothing

cnn.Close
Set cnn = Nothing
pclement at 2007-11-11 23:49:14 >
# 4 Re: ADO wildcard?
hey thnx, i tried without the schema, it wrks (except 4 the fields with wildcards).
the thing is, this prob happens when i bind the data into crystal.
-->
ISectionPtr pSection = GetReportSection(3);
IFieldObjectPtr pFieldObj = 0;
LocX = 10; // Horizontal offset
VARIANT var;
VariantInit (&var);
var.vt = VT_DISPATCH;
BSTR objName = NULL;
var.pdispVal = FNameFormula;
pFieldObj = pSection->AddFieldObject(var, LocX, 0);
CComBSTR bar;
HRESULT hrr=SysReAllocString(&objName, CComBSTR(L"F_Name"));//prob!
pFieldObj->put_Name(objName);
pFieldObj->put_Width(2600);
LocX +=2100;
-->
program simply ignores field 'F_Name' and prints the other fields!
Niro1983 at 2007-11-11 23:50:25 >
# 5 Re: ADO wildcard?
If you don't get a solution here, you might try Crystal's tech support site: http://support.businessobjects.com/
Phil Weber at 2007-11-11 23:51:21 >