Read Table Description Into ADODB.Recordset.
Aug 20, 2003How do I read the Tables description into ADODB.Recordset and then recreate the Tables+description into a new database from the ADODB.Recordset.
View 1 RepliesHow do I read the Tables description into ADODB.Recordset and then recreate the Tables+description into a new database from the ADODB.Recordset.
View 1 Replieshi have written SSIS script and i am using script component to Row count below my code what i have written. and i am getting error below i have mention...after code see the error
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Data.SqlClient;
using System.Data.OleDb;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
IDTSConnectionManager100 connMgr;
OleDbConnection sqlConn = null;
OleDbDataReader sqlReader;
public override void AcquireConnections(object Transaction)
{
connMgr = this.Connections.MyConnection;
sqlConn = (OleDbConnection )connMgr.AcquireConnection(null);
//sqlConn = (SqlConnection)connMgr.AcquireConnection(null);
}
public override void PreExecute()
{
base.PreExecute();
/*
Add your code here for preprocessing or remove if not needed
*/
OleDbCommand cmd = new OleDbCommand("SELECT CustomerID,TerritoryID,AccountNumber,CustomerType FROM Sales.Customer", sqlConn);
sqlReader = cmd.ExecuteReader();
}
public override void PostExecute()
{
base.PostExecute();
/*
Add your code here for postprocessing or remove if not needed
You can set read/write variables here, for example:
Variables.MyIntVar = 100
*/
}
public override void CreateNewOutputRows()
{
/*
Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
*/
System.Data.OleDb.OleDbDataAdapter oLead = new System.Data.OleDb.OleDbDataAdapter();
//SqlDataAdapter oLead = new SqlDataAdapter();
DataSet ds = new DataSet();
System.Data.DataTable dt = new System.Data.DataTable();
//DataRow row = new DataRow();
oLead.Fill(dt,this.Variables.ObjVariable);
foreach (DataRow row in dt.Rows)
{
{
Output0Buffer.AddRow();
Output0Buffer.CustomerID = (int)row["CustomerID"];
Output0Buffer.TerritoryID =(int)row["TerritoryID"];
Output0Buffer.AccountNumber = row["AccountNumber"].ToString();
Output0Buffer.CustomerType = row["CustomerType"].ToString();
}
}
}
}
the error
Script component has encountered an exception in user code
Object is not an ADODB.RecordSet or an ADODB.Record.
Parameter name: adodb
at System.Data.OleDb.OleDbDataAdapter.FillFromADODB(Object data, Object adodb, String
srcTable, Boolean multipleResults)
at System.Data.OleDb.OleDbDataAdapter.Fill(DataTable dataTable, Object ADODBRecordSet)
at ScriptMain.CreateNewOutputRows()
at UserComponent.PrimeOutput(Int32 Outputs, Int32[] OutputIDs, PipelineBuffer[] Buffers)
at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput(Int32 outputs,
Int32[] outputIDs, PipelineBuffer[] buffers)
thanks
kedarnath
I am trying to access a table that I know exists and has data. But, when I create a recordset and check for RecordCount, I get a result -1 (no records). When I access the same table (using the same program), it reports (and I can view in a dbgrid) 752580 records exist.
Here's some of the code:
The table is originally copied from another database; I use the following code to be sure the previous connection is closed before proceeding.
If Not adoRS Is Nothing Then
If adoRS.State = adStateOpen Then adoRS.Close
Set adoRS = Nothing
End If
If Not DbConn Is Nothing Then
If DbConn.State = adStateOpen Then DbConn.Close
Set DbConn = Nothing
End If
Then a new connection (it works) is opened to access the database with the copied table:
strDbConn = "Provider=SQLNCLI;Integrated Security=SSPI;" & _
"Persist Security Info=False;Database=" & strDbName & ";" & _
"AttachDBFileName=" & DbPath & ";Data Source=.sqlexpress;" & _
"User Instance=True"
Next I tried to create the recordset:
Set adoNewRS = New ADODB.Recordset 'Set OHLC recordset
Set adoNewRS.ActiveConnection = DestDbConn
adoNewRS.Open TableName, DestDbConn, adOpenDynamic, adLockOptimistic
Next I try to get the RecordCount:
NumRecords = adoNewRS.RecordCount
At this point, NumRecords (and adoNewRS.RecordCount) = -1 (even tho I know there are 752580 records in the table).
In the adoNewRS.Open statement, I also tried using the following sql statement:
sSQL = "SELECT * FROM TableName ORDER BY [DateTime];"
It also returns a recordcount = -1.
Anybody have clue?
I've been trying different things to "READ" the recordset from the "Message Queue". I can read it but with some weird characters. I've tried
ActiveXMessageFormatter
BinaryMessageFormatter
XMLMessageFormatter
So, far I have no luck.
MessageQueue msgQ3 = new MessageQueue("SERVERNM\" + msg.Label, false);
Message msg3 = new Message();
msg3.Formatter = new ActiveXMessageFormatter();
msg3 = msgQ3.Receive(new TimeSpan(0, 0, 30));
byte[] b = new byte[msg3.BodyStream.Length];
msg3.BodyStream.Read(b, 0, (int)msg3.BodyStream.Length); System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
returnVal = enc.GetString(b);
RESULTS:
I try to convert it to String and then deserialize later but I'm getting some junk.
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="http://tempuri.org/">5??m.????????#?_?XTG!???????#?_?Xg??c??????? ?<???m????_?X |?"???????Dw=?????"I?<???m????_?X21? Reply_Code?$??5? MultiEntries?$??7?dName?.$??3? Page_Number?$??1? Number?$??3? Status_Code?$??/?_Name?.$??5? _Address?+$??/? B_City?$$??1? _State?$??-? _Zip?$??A? Bank_Telephone_Num?"$?? ??11 033000333YHONDA2nd street xavier VA 326200000(555) 555-5500</string>
Is there any SQL Error?Or I have to use Select case in VB code to control SQL instead.Thank you for any ans.Nuno
View 4 Replies View RelatedHi,
I used adodb connection and recordset in script task. but i have an error saying adodb is not defined. how do i add it to reference? or, is adodb can run in script task or only ado.net?
cherrie
Hi,
I am using the following code
I use SQLOLEDB Provider
It is not stored porcedure but program code
create new global temporary table with
CREATE TABLE ##tmp123 (...
create and open a recorsset to populate it as direct table
at the open stage I get the following error: Invalid object name '##tmp123'
How can I get it working?
Somehow, (I think the user ran a registry cleaner) on Vista, I can no longer create an adodb recordset object.
The app is a VB6 app that works fine on my own Vista Ultimate, my XP boxes and about everthing else prior, but not on the one Vista Home Premium.
I get Error 429 ... Cannot Create ActiveX Object when creating a new adodb.recordset object.
I guess what I need is a way to repair the Vista Home-P machine without having to wipe it.
I see that MDAC_Typ is not recommended as a fix.
I'm at a loss on this one.
Hey,
I'm using CRecordSet to add new rows to some table.
The Sequence of operations is as following:
m_recSet->Open();
m_recSet->AddNew();
m_recSet->Update();
In the AddNew() function i'm getting an Exception Saying "Recordset is read-only".
I saw in previous posts that this problem is caused when there is no Primary Key, but, my table
does not have a Primary Key and i don't want to set one.
How can i add rows to a table that doesn't have Primary Key ?
Thank
Shahar
Hello,I have a C++ / MFC app which uses CDatabase and CRecordset to connect to aODBC data source for a SQL Server 7 database. The application workedproperly with a MySQL database, but after swapping it for SQL Serverproblems emerged. In particular, any calls to CRecordset::AddNew() andCRecordset::Edit() cause an exception to be thrown with the error message"Recordset is read-only". Stepping through the code for CRecordset::Open(),I can see that it indeeds fail to open the recordset with SQL_CONCUR_ROWVERand SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need tobe able to write to the db!! What is going on here??I call CRecordset::Open() with no SQL string and no options (which defaultsto full access and not read-only).I am not a SQL Server expert, but I tried playing with the config a littlebit:- The database is NOT set for read-only.- The database option "Restrict Access" is NOT selected.- I checkmarked all permissions (SELECT, INSERT, UPDATE, DELETE, DRI)for my app's user on all tables in the db.- My connection string uses the user 'sa', which is the login name forthe user 'dbo'.In the ODBC data source config, I set authentication to SQL Serverauthentication, and accepted the default for all the other options.I haven't tried using a different class (say, CDaoRecordset) nor do I planon doing that. I really need to get this to work with CRecordset. Any helpis appreciated.Thanks,SL
View 3 Replies View RelatedI have an application which runs successfully on a couple of my customer's machines but fails on a third. It seems to fail when opening the database:
Unable to cast COM object of type 'ADODB.CommandClass' to interface type 'ADODB._Command'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B08400BD-F9D1-4D02-B856-71D5DBA123E9}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=false; Initial Catalog=lensdb;Data Source = SQL
Before I got this error I was getting another problem (sorry didn't make a copy of that error's text) that made me think that adodb.dll simply wasn't loaded/registered. I got rid of that error by copying my adodb.dll onto the third machine and running gacutil /i. There is now an entry in winntassemblies for adodb.
Just in case you think it could be an obvious registry problem: when I started getting the current error I thought that maybe the registry needed updating and I merged the following lines into onto the target machine (from my dev machine):
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOTInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}]
@="_Command"
[HKEY_CLASSES_ROOTInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}ProxyStubClsid]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOTInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOTInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}TypeLib]
@="{EF53050B-882E-4776-B643-EDA472E8E3F2}"
"Version"="2.7"
[HKEY_LOCAL_MACHINESOFTWAREClassesInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}]
@="_Command"
[HKEY_LOCAL_MACHINESOFTWAREClassesInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}ProxyStubClsid]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_LOCAL_MACHINESOFTWAREClassesInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_LOCAL_MACHINESOFTWAREClassesInterface{B08400BD-F9D1-4D02-B856-71D5DBA123E9}TypeLib]
@="{EF53050B-882E-4776-B643-EDA472E8E3F2}"
"Version"="2.7"
but, no change alas.
All three machines are running Windows 2000.
Any advice would be appreciated.
Thanks in advance,
Ross
Hi Experts,
Im trying to insert a record from Excel [Sheet2$] from Range (A2) to Range (E2) into a table on MS SQL server:
But I get the following error:
Error-2147217900(The INSERT INTO statement contains the following unknown filed name:F1).
Here is the ADODB.Connection:
Sub DB_con1()
Dim cn As ADODB.Connection
Dim strSQL As String
Dim lngRecsAff As Long
On Error GoTo test_Error
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=D:Book1.xls;" & _
"Extended Properties=Excel 8.0"
'Import by using Jet Provider.
strSQL = "Insert INTO [odbc;Driver={SQL Server};" & _
"Server=titan;Database=dev;" & _
"UID=sa;PWD=welcome1@].abk_import " & _
"Select * FROM [Sheet2$]"
Debug.Print strSQL
cn.Execute strSQL, lngRecsAff ', adExecuteNoRecords
Debug.Print "Records affected: " & lngRecsAff
cn.Close
Set cn = Nothing
On Error GoTo 0
Exit Sub
test_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure test of VBA Document ThisWorkbook"
End Sub
Thanks in advance for any help.
Regards,
Abraham
Ok, so I can connect to the database without any errors, however im not sure about the syntax for filling a table. Heres what i have so far in the pageload. Like i said this all works with out any errors. Thanks in advance for the help.testDS = New DataSet()
testDataTable = New DataTable("Tbl")testDataTable.Columns.Add("username")
testDataTable.Columns.Add("datecompleted")testDataTable.Columns.Add("lastfive")
testDS.Tables.Add(testDataTable)Me.dgrdSearch0.DataSource = testDS.Tables("Tbl")
Dim Conn As Object = Server.CreateObject("ADODB.Connection")
Dim strConn = "DRIVER={SQL Server};SERVER=serverName;UID=userID;PWD=password;DATABASE=net"Dim DSNtest As String = strConn
Dim sql As String = "SELECT * FROM Tbl"
Conn.open(DSNtest)
Conn.close()
I need to find out if a Transaction ID exists in Table A that does not exist in Table B. Β If that is the case, then I need to insert into Table B all of the Transaction IDs and Descriptions that are not already in. Seems to me this would involve If Not Exists and then an insert into Table B. Β This would work easily if there were only one row. Β What is the best way to handle it if there are a bunch of rows? Β Should there be some type of looping?
View 12 Replies View Relatedi want get fields description in structure tables that i madetables.please help me for resolve this problem .thank you
View 2 Replies View RelatedHi All,In SQL Server how can I get the descriptions of tables in adatabase?From MSDN help I could find a way to get the description of columnsusing the following extended propertySELECT *FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table','Reports', 'column', default)ThanksRegardsSobhan
View 1 Replies View RelatedIn oracle there is a describe command:
describe table_name
This command will tell you the columns names, datatypes, and length of the columns for that particular table. Does anyone know if there is a simliar command in SQL server that would do that? The only way that I have found so far is to do a join of the syscolumns with sysobject by table name.
Hi everyone,
I'm using SQL 2005. I want to add a description for each table on my database. How do I do that? I know I can add a description to each field, but how do I add a description to each TABLE? I tried going to Properties but don't see anything.
Grateful for any help. Thanks.
Newby question but can't find it myself.How can I get a file-description from a file / table ?eg. the decription must deliver the following info:Record nr.Field nr.FieldnameField descriptionData typeLenghtDecimalsetc....Can somebody please tell me what to do?ThanxMF
View 5 Replies View RelatedHow can I query/script Column or Table description (extended property MS_Description') in SQLserver 2005 db.
View 4 Replies View RelatedThe Description field in SQL Server 2005 Reporting Services just defaults to "Send e-mail to email@domain.com" (obviously a dummy e-mail address) when you create an e-mail subscription. You cannot edit the Description when you select "Edit" beside a subscription.
The Description may be edited directly in the Subscriptions table under the ReportServer database but this is not end-user friendly.
I thought of using an add/update trigger to set the Description to the "Subject" out of the Extension Settings field. The Extension Settings field is XML so you would have to parse the Subject out of there first. The "Subject" is the e-mail Subject for the e-mail that is sent to the subscriber and it much more adequately describes the report.
My boss understood what I wanted to do but wanted to make sure in the industry literature that the product was not that lacking. Hard to believe that you cannot directly edit the Subscription Description through the web browser interface - would love for someone to prove me wrong.
I want to ask something because i need.
Any SQL/T-SQL command inside MsSQL Server 2000 can show the description of {all table columns or specified table columns} of specified table inside specified database?
can you teach me how to do and any example(s)?
Assume that if i have a product called Jacket that has the following descriptions, which written in bullet form
β’ 600 Denier Carbolex® coated 1000mm Polyurethane
β’ Anatomically fitted for the riding position
β’ Ballistic nylon in protective areas
β’ FS Rainguard® 100% waterproof/breathable jet-liner
β’ Polyester mesh non-allergenic liner
β’ Removable CE armour equipped in the hips and knees
β’ Padding at knees, shin, hips and kidney area
β’ Removable zip-out satin quilted liner
β’ Reflective Phoslite®
β’ Stretch in the knees
β’ Gusseted with Velcro front zip closure
β’ Velcro adjustable waist
β’ 2 front pockets
β’ Storm flap system
How am i going to store in the Products table ? But not all products have these descriptions, other products may have no description at all.... If I store them in a text/memo DESCRIPTION field, then , I do not know how to format them into bullet form...
I would appreciate anyone knows the solution for me... Thanks in advance !
I am trying to get the schema of database using the getschema method. However, the schema that is being returned does not include the description. I have added in table and column descriptions for some of my tables and columns but the dataset returned does not include the description column.
Any idea on how to get the description to be output?
Dim testCn As System.Data.OleDb.OleDbConnection
testCn = New System.Data.OleDb.OleDbConnection(step2.GetRevEngConn.ConnectionString)
Dim testDS As DataTable
testCn.Open()
testDS = testCn.GetSchema("TABLES")
testds.writexml("c:schematables.xml")
testDS = testCn.GetSchema("COLUMNS")
testDS.writexml("C:schemacol.xml")
testCn.Close()
- <Columns>
<TABLE_CATALOG>XDMDB_LAPTOP</TABLE_CATALOG>
<TABLE_SCHEMA>dbo</TABLE_SCHEMA>
<TABLE_NAME>PropertyValue</TABLE_NAME>
<COLUMN_NAME>property_value</COLUMN_NAME>
<ORDINAL_POSITION>6</ORDINAL_POSITION>
<COLUMN_HASDEFAULT>false</COLUMN_HASDEFAULT>
<COLUMN_FLAGS>230</COLUMN_FLAGS>
<IS_NULLABLE>true</IS_NULLABLE>
<DATA_TYPE>130</DATA_TYPE>
<CHARACTER_MAXIMUM_LENGTH>0</CHARACTER_MAXIMUM_LENGTH>
<CHARACTER_OCTET_LENGTH>0</CHARACTER_OCTET_LENGTH>
<CHARACTER_SET_CATALOG>master</CHARACTER_SET_CATALOG>
<CHARACTER_SET_SCHEMA>dbo</CHARACTER_SET_SCHEMA>
<CHARACTER_SET_NAME>iso_1</CHARACTER_SET_NAME>
<COLLATION_CATALOG>master</COLLATION_CATALOG>
<COLLATION_SCHEMA>dbo</COLLATION_SCHEMA>
<COLLATION_NAME>SQL_Latin1_General_CP1_CI_AS</COLLATION_NAME>
<COLUMN_LCID>1033</COLUMN_LCID>
<COLUMN_COMPFLAGS>196609</COLUMN_COMPFLAGS>
<COLUMN_SORTID>52</COLUMN_SORTID>
<COLUMN_TDSCOLLATION>CQTQADQ=</COLUMN_TDSCOLLATION>
<IS_COMPUTED>false</IS_COMPUTED>
</Columns>
I have a question regarding saving hashtags in another table. I have two tables with these columns:
Table1
ItemId, Name, Description (it may contains several hashtags like this example "hey I am an #example of this #question")
Table2
HashtagId, ItemId, Hashtag
So I want to detect #example and #question and put them in Table2. I'd like to create a trigger for table1 that if there was a hashtag, it added a record in table 2.
CREATE TRIGGER [dbo].[tr_Events_ForInsert_Hashtag]
ON Table1
FOR INSERT
AS
BEGIN
DECLARE @ItemId bigint
SELECT @ItemIdΒ = ItemIdΒ FROM inserted
[Code] .....
I have 'codes' and 'Description' field in 'ecode' table and 'codes' in quote table values for 'Codes' in quote table is like
Quoteid Codes
0012 LB,WS
0031WDC
In 'ecode' table 'description' column contain the description for each code
for eg :
Ecode Table : -
Codes Description
Lb - Late Booking
WS - Winter Sports
WDC - Wedding Cover
How to select 'description' when retrieving data from quote table
I live in Brazil, and use SQL Server 2000 SP4 with Visual Basic 5.0 SP3, with connectivity to ODBC through RDO/ADO.
I have an example table with the following structure:
Table Name: Autioneer's (translated from Portuguese)
'Field 1/3
Name: Code
DataType: int
Description: Auctioneer's Code
'Field 2/3
Name: Name
DataType: nvarchar(50)
Description: Auctioneer's Name
'Field 3/3
Name: RegNum
DataType: nvarchar(20)
Description: Auctioneer's Registration Number
I need a way to programatically extract the Fields Description Property from the table
example sintaxe:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='AUCTIONEERS'
Thanks for any help that can be offered here
Neil Ramkeerat.
Replies can be sent to neilramkeerat@hotmail.com
I have a subselect that should be working but doesn't. Been at it too long today.
DECLARE @Calendar1 AS DateTime
SET @Calendar1 = '{{{ Please choose a start date. }}}'
SELECT
('0' + CONVERT (varchar (10), W.WorkerID)) AS VendorID,
(W.FirstName + ' ' + W.LastName) AS VendorName,
(W.FirstName + ' ' + W.LastName) AS Contact,
[code].....
Where did I go wrong?
Hi,
I want to implement error handling my SSIS package. for this I am putting an execute SQL task for a container(which contains different interlinked tasks) in event handler.
Say my first task fails in this container.Immedaitely my sql task which inserts the error code and description should exceute in the event handler and populate my error table in OLAP database.
Any help will be great SSIS gurus.
Thanks in advance.
Regards,
Aman
I want to transfer a recordset (derived from an Oracle datasource) into
an SQL2000 Server table using VBScript in a ActiveX Script Task using a DTS.
Currently I use the OPENROWSET (and OPENQUERY) method, however
the lenght of the querytext seems to be limited to 8192 bytes.
At this moment I have reached the limit of this lenght, and I am looking
for a solution.
Futher info: The query returns large recordsets of 100,000s of records with 100s of columns. Because of it's complex structure, the standard data transformation in SLQ2000 is not an option.
Using a substitute like:
varRecords = rst1.GetRows
For intI = 0 To UBound(varRecords, 2)
rst2.AddNew
For intJ = 0 To UBound(varRecords, 1)
rst2(intJ) = varRecords(intJ, intI)
Next
Next
rst2.Update
works fine but is much to slow.
Can anyone help me to find a solution?
I have a table defined as (int Row, int Column, money Data); as it were a matrix.
Which is the more efficient way of retrieving a result set with the following form?
Column1 Column2 Column3
---------- ----------- ----------
Data11 Data12 Data13
Data21 Data22 Data23
Data31 Data32 Data33
... ... ...
Thanks a lot in advance.
I need to call a sproc about 1000 times and build a table from all the results.
How do I write an insert statement that will take the recordsets from the sproc and put it into a temp table?
I tried to create a dynamic table, fill in it and return it as recordset. The codes as this:
Declare @tbl Table(id int, name varchar(100), age int)Β
Insert Into @tbl(id, name, age)
Values(1, 'James, Lee', 28),
Β Β (2, 'Mike, Richard', 32),
Β Β (3, 'Leon Wong', 29)
Select * From @tbl Order By age
It works well in "SQL Query Ananizer". But return no records in ASP page.