 |
|
 |
Hi,
I use your codes and everything looks fine but the 'Sort' property doesn't work for the converted Recordset.
My codes are like following:
ADODB.Recordset result = new ADODB.Recordset();
result = ConvertToRecordset(dt);
result.Sort = "field_a";
Seems the converted recordset doesn't support 'Sort' property. Any help would be appreciated.
|
|
|
|
 |
|
 |
I am getting this error when I try and convert one of my database table to a recordset. I have narrowed it down to one column which is a System.TimeSpan type. I have tried converting this type to adVariant, adDate, adDBDate, adDBTime, adDBTimeStamp. but all of these produce the same error as above. What type should this be converted to?
|
|
|
|
 |
|
 |
I suspect the best thing would be modelling it as a long, but I don't have any code like that around anymore.
http://musingmarc.blogspot.com
|
|
|
|
 |
|
 |
I'm not quite sure why this is happening, so I'm curious if anybody else has seen this problem. I have a DataSet that has some string data types in it. When this code first creates the recordset and inserts the data with the Append method, the data type is adVarChar as it should be given the TranslateType method results (I put a watch on result.Fields["Name"].Type). As soon as the Open method is called on the Recordset, all of those adVarChar types become adLongVarChar.
Most things behave fine with this change, except for the fact that I can't set the Sort property on a field with type adLongVarChar.
Any ideas as to why this is happening?
Thanks
|
|
|
|
 |
|
 |
Sounds like the column you are selecting is a text, ntext, varchar(max) or nvarchar(max). Without schema it is very hard to know.
http://musingmarc.blogspot.com
|
|
|
|
 |
|
 |
Thanks for the quick response. Of course, right after I posted I realized that inColumn.MaxLength is always returning -1. That is what is causing the adVarChar to become adLongVarChar when the recordset is opened. When I was populating my DataSet, I only called Fill and missed FillSchema. After I changed my code to the following, things seem to be working great.
SqlCommand cmd = new SqlCommand(sql, connectionString);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
da.FillSchema(ds, SchemaType.Source);
Thanks for the helpful article!
|
|
|
|
 |
|
|
 |
|
 |
The provided code is helping on parsing a datatable to a recordset, which we use in a Microsoft Office Spreadsheet Web Component (OWC11).
Unfortunately I get a bunch of errors when a TIME column is involved, I see the time data as for instance "09:45:13" in the datatable, but I get as many "A first chance exception of type 'System.ArgumentException' occurred in ADODB.dll" errors as there are rows...
and after the parsing I have all my data in the OWC except for the Time column, which is empty...
Adding a statement
Case "System.TimeSpan"
Return ADODB.DataTypeEnum.adDate
in the TranslateType Function does not resolve anything, even if the type is indeed a System.TimeSpan...
Phil
|
|
|
|
 |
|
 |
It should probably be converted to a "ADODB.DataTypeEnum.adDBTimeStamp" since this is what all OLEDB types need to be for Date / Time values.
|
|
|
|
 |
|
 |
I have worked alot with adodb. I have tryed a couple of times to switch to ado.net, but my project deadlines have never allowed time for the learning curve. Do you know any good articles that would quickly explain how to use ado.net bassed on a general knowledge of adodb. Your article gave me several clues as to how they relate, but i still am missing a few pieces of the puzzel. Like how to connect to a database and how to run a stored procedure.
Thanks
|
|
|
|
 |
|
 |
I am in the process of creating a CCW for a .net assembly for my company. I needed a quick way of converting DataTables to ADODB.Recordset objects and I stumbled upon your article. Excellent code by the way!
However, during the execution of my code I ran into a bit of a problem with at SQL type of DBTimeStamp. As I'm sure your aware this is a binary type in SQL, and as such, is treated at an array of bytes. Fair enough. Unfortunately when this snippet of code runs:
for (int columnIndex = 0; columnIndex < inColumns.Count; columnIndex++)
{
resultFields[columnIndex].Value = dr[columnIndex];
}
I get an exception of type "System.Runtime.InteropServices.COMException". It seems to be when the column of type "System.byte[]" is getting copied over the whole thing blows up. Just wondering if you had a fix for this, or any ideas as to what the problem really is.
Thanks,
Josh
|
|
|
|
 |
|
 |
Ok, so I am a moron...
I realized that the conversion list only accounted for the
"System.Byte" type
and not the
"System.Byte[]" type
Not sure how I missed that distinction, but everything is Kosher now I am going to drink another RedBull and try to wake up
Thanks,
Josh
|
|
|
|
 |
|
|
 |
|
 |
You should have used "ADODB.DataTypeEnum.adVarBinary" since your byte array can be different lengths. If you are ABSOLUTELY sure that all your columns values are exactly the same length, then adBinary is fine. However, this is usually not the case.
Just think of how SQL Server handles Binary and VarBinary data types.
|
|
|
|
 |
|
 |
Thanks for the contribution.
The article helped me to solve a problem with AddNew which I wasn't able to solve for a couple of hours.
|
|
|
|
 |
|
 |
Wow, blast from past. Glad it helped.
http://musingmarc.blogspot.com
|
|
|
|
 |
|
 |
Hi,
I am using the function but I have the following problem
1) I have 20 records in DataSet.
2) the conversion function is executed well, but when I review the RecordSet appears only one record. Where this the problem?
Thanks for its commentaries
|
|
|
|
 |
|
 |
Sorry,
result.MoveFirst();
|
|
|
|
 |
|
 |
You need to call the Update method on the Recordset in order for the new Records to appear:
if (rs.EditMode != ADODB.EditModeEnum.adEditNone) rs.Update(Missing.Value, Missing.Value);
|
|
|
|
 |
|
 |
Hi all,
First of all I would like to give thanks to Marc Brooks by excelent article.
I found the same problem than rbarzallo, I tried the Tim McCurdy's solution: (if (rs.EditMode != ADODB.EditModeEnum.adEditNone) rs.Update(Missing.Value, Missing.Value)) but the problem still persist.
Somebody can help me?
Tks,
Cleber
|
|
|
|
 |
|
|
 |
|
 |
When I try the example I get the error 'The type or namespace ADODB can not be found.' I assume I need a 'using' directive, but I don't know which one.
|
|
|
|
 |
|
 |
Hi Jon,
You must reference the ADODB Com object inside your project.
The system will create automatically a wrapper .NET <--> COM to enable communication between .net and the com object.
Hope this helps.
Rgds,
Franck.
|
|
|
|
 |