|
I have started working on a project where I will collect all metadata from a specific sql server database. I have got so far that I can collect the names of all tables and the names and datatypes of all columns in the tables.
Now I need to check what column is set as the primary key (if any) in each table. This has caused me some troubles. In the sysobjects table there are rows for every primary key. The look something like this: PK__Customers__78B3EFCA. Here PK is the name of the column and Customers is the name of the table. There must be a better way to control the name of the primary key column than to check the string above.
The other problem is also about the primary key. Often the primary key is set to be autonumbered. How can I control this? In a table I created recently I created this T-SQL script:
CREATE TABLE Accounts
(
AccountNr int PRIMARY KEY IDENTITY(100001, 1),
OwnerFK int,
Amount float
)
Is it possible to get all that information about the primary key?
|
|
|
|
|
EXEC sp_pkeys 'Accounts'
SELECT COLUMNPROPERTY(OBJECT_ID('Accounts'),'AccountNr','IsIdentity')
|
|
|
|
|
How do I get the MSI installer to proceed with a MSDE install again?
It is not in Add/Remove and Ic na not find much in the registry.
Are there 'magical' hidden files somewhere? That MSI will look at for 'product is installed' indicators or something?
|
|
|
|
|
One component returns me an instance of IDBConnection. But I need an instance of
OleDBConnection class. I have no control over the component. Please advise.
|
|
|
|
|
Hi,
I am binding a DataTable to a DataGrid. To push the changes from
DataTable to the actual database I need to use OleDbCommandBuilder.
I have an instance of IDbDataAdapter. The restriction is that I
cannot create instances of OleDbDataAdaper. Also OleDbCommandBuilder
constructor does not accept IDbDataAdapter as a parameter.
Is there a workaround.
Help is appreciated.
Thanks and Regards,
Alomgir
|
|
|
|
|
Alomgir Miah wrote:
I have an instance of IDbDataAdapter
This is being pedantic, but you don't have an instance of IDbDataAdapter . That is an interface and you cannot instantiate interfaces or abstract classes, you can only instantiate concrete types like an OleDbDataAdapter . You have an IDbDataAdapter reference to a concrete type, i.e. something that inherits from IDbDataAdapter .
Alomgir Miah wrote:
The restriction is that I cannot create instances of OleDbDataAdaper
To create OleDbDataAdapter objects you need to place a
using System.Data.OleDb;
line at the top of the file. The documentation for the OleDbDataAdapter class[^] says this.
Quite probably you already have an OleDbDataAdapter that your are referencing through the IDbDataAdapter interface. If this is the case all you need to do is cast it to an OleDbDataAdapter in order to use it. You do that like this:
(OleDbDataAdapter)myIDbDataAdapterReference
Finally, and this is because it is a pet hate of mine, don't use command builders. They give false hope, and they hide from you what is actually going on. For more information, read this excellent article: Weaning Developers from the Command Builder[^]
Does this help?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Beginner question. I just finished a class where we learned to access an Oracle or Access database through a network connection and then used SQL to query the data.
I want to simulate a network connection on my home computer for further study.
What do I need to do to do this?
What are the basic steps?
Please excuse my ignorance, but this is all very new to me... - thanks
|
|
|
|
|
If you have installed Access or Oracle in your PC, then all the programs that you made will run in your computer. You just need to change the connection string used by your program and create similar databases in your pc.
|
|
|
|
|
okay so i have this
myCommand.CommandText = "INSERT into UserID (UsrName, passwr, UsrID) VALUES ('Rik', 'pass', 9)";
now what i want is to have a user enter in the UsrName and passwr value. what is the syntax to do that using what ever they entered to be added to the database.
also if i want to delete a row by UsrName, but the user entered the UsrName, how do i do that?
|
|
|
|
|
i did this and am getting an error now...
it tells me one or more required parameters are not filled
<br />
string UserName = txtUsrName.Text;<br />
string UserPass = txtUsrPass.Text;<br />
<br />
StringBuilder addstring = new StringBuilder();<br />
addstring.Append("INSERT into UserID (UsrName, passwr) VALUES (");<br />
addstring.Append(UserName);<br />
addstring.Append(", ");<br />
addstring.Append(UserPass);<br />
addstring.Append(")");<br />
<br />
string sqlString = addstring.ToString();<br />
OleDbCommand myCommand = new OleDbCommand();<br />
myCommand.CommandText = sqlString;<br />
myCommand.Connection = myConnection;<br />
myConnection.Open();<br />
myCommand.ExecuteNonQuery();<br />
myConnection.Close();
argh, what did i do?
|
|
|
|
|
Hi,
I use
ADODB.Connection
ADODB.Command
ADODB.Recordset
ADODB.Parameter
to access stored procedures on db. Now I should call a function which is overloaded e.g.
function oLoaded(first in varchar2, second in varchar2)
and
function oLoaded(first in varchar2, second in varchar2, third in varchar2,fourth in varchar2)
the Execute to second function with 4 params works, but if I want to call the first I get the run time error 80040e14 'wrong number or types of arguments in call to oLoaded'!!???
thx for help
greets
|
|
|
|
|
I can see the following line in the log file if the MSDE setup is successful:
"MSI (c) (5C:A8): Product: Microsoft SQL Server Desktop Engine -- Installation operation completed successfully."
Can soemone tell me what the line will be if the reboot is required?
I need to detect a reboot required for an automatic installation.
Thanks.
|
|
|
|
|
Hello All,
I have a requirement wherein have 2 sql server databases(say machine1 & machine2).
I want to run a sql query on machine1 , which would copy 5 tables in a 'XYZ' database on machine2 TO 'XYZ' database on machine1.
Note : I have user/password for both the machines.
I tried this using BCP utility, but problem using BCP is, exceptions cannot be handled And if there is a network failure during the process of data transfer , the process console window window of BCP utility, remains still(stuck) and needs user input to continue.
Please send me a QUERY(I already know about the Export/Import in SQL Server Enterprise Manager, but i need a query to run from vc++) to copy tables between 2 sql servers. that query, i should be able to place between BEGIN & COMMIT Transaction Process.
Waiting for ur reply.
Regards,
Prax.
|
|
|
|
|
If the tables do not exist in 'XYZ' database in machine1 the use sqldmo object(try google to sample code) to generate the create schema script and execute it on machine1. then generate dynamic insert statements from say 'Table1' in machine2 as
select
'INSERT TABLE1 (ID, Name, Description) Values(' + CAST (ID as char(50)) +
',''' + CAST (Name as char(50)) + '''' +',''' + CAST (Description as char(50)) + ''''
from Table1
Here ID, Name and Description are the fields of Table1.
This query will generate the insert statements for Table1 you need to execute on Machine1.
Generate for all the tables, execute the create schema script and then execute the generated inserts in a single transaction.
Guess this works for you.
|
|
|
|
|
could any one please provide me with the connction string to connect to sql database with the server IP adrress,databse name,user id and password
This Page is developed using ASP
|
|
|
|
|
www.connectionstrings.com
This should most of your Connection string problems.
|
|
|
|
|
search for article on this site called "ADO connection strings". With or without ADO, the connection strings still work
while(true)
{
TryToLearn("C++,MFC");
}
My articles[^]
bdiamond
|
|
|
|
|
|
|
hi
I have a class(eg CMyClass) with a data member which is a _RecordsetPtr ,bind with a table of ORACLE which has a CLOB field.
class CMyClass
{
_RecordsetPtr m_pRst;
public:
void SomeMethod(CString strContent)
{
IDBAccessPtr o(__uuidof(DBAccess));
m_pRst = o.GetRecordset(_T("select * from tbl_a where id = 0"));//select an empty recordset
m_pRst->AddNew();
m_pRst->PutCollect(_T("id"),lDataId);
m_pRst->PutCollect(_T("content"),(LPTSTR)(LPCTSTR)strContent);
o.UpdateRecordset(m_pRst);
}
};
structure of tbl_a is:
create table tbl_a
(
id number(10,0),
content clob
)
/
using of CMyClass:
void UseOfMyClass(CString str)
{
CMyClass obj;
obj.SomeMethod(str);
}
First call UseOfMyClass with a very long string as parameter,is ok.
then call UseOfMyClass again(and all the succeeding calling ),the system issue a messagebox say:
""在对应所需名称或序数的集合中,未找到项目。
0x800a0cc1"
means "Item cannot be found in the collection corresponding to the requested name or ordinal"
if first calling of UseofMyClass with a shorter string parameter and the second call to UseofMyClass does not issue error and the result is correct.
I don't know why ,is there a stack overflow in _Recordset Object after handle a very long string ?
Help me please!
thanks advaced.
|
|
|
|
|
It seams that the stack of the app has been destroyed,because when then app exit if it execute the First call UseOfMyClass with a very long string as parameter,the system issue:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: E:\mytest.exe
File: dbgheap.c
Line: 1044
Expression: _CrtIsValidHeapPointer(pUserData)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
终止(A) 重试(R) 忽略(I)
---------------------------
unless it's ok.
|
|
|
|
|
Running SQL, and building a searchable datagrid. A how to from microsoft, Article number 308070 (Q308070). I keep getting a break at my fill line. I rewrote this code three times, same error. I have a funny feeling the code is wronf in the article, can someone take a peek, and see if it seems right? Thanks!
http://support.microsoft.com/default.aspx?scid=kb;en-us;308070
|
|
|
|
|
i have a single table in northwind data base its contain a one row and two columns UserName ,Pass...when i made change to the pass...i found exption
invalid operation...and here is the in c#
ds.Tables["Test"].Rows[0]["Pass"]="dodo";
sqlConnection1.Open();
cmdB=new SqlCommandBuilder(ad);
ad.Update(ds);
sqlConnection1.Close();
hi i am ezak neno
|
|
|
|
|
The SqlCommandBuilder is a black box (stuff goes in. Something happens. Stuff comes out. What happens? Who knows?) - You should, IMO, learn how to construct your own update statements. That way you will know what you've written and if anything goes wrong you will have more chance of tracking it, and understanding why it went wrong.
From MSDN: Weaning developers from the CommandBuilder[^]
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
I have a table in sqlServer with some columns if dateTime values (date + time)
I wrote a stored procedure that select those columns, the stored Procedure works properly.
I tried to retrieve the data into dataSet and then to dataGrid. I get a very nice datagrid with the whole data, but the coulumns of datatime values show only the date. I need the time also.
How can I get it?
I know that there is some types of datacolumn like dataGridBoolColumn or dataGridTextBox column, but I couldn't find dataGridDateTimeColumn.
Thank you;)
|
|
|
|