|
|
How do we retreive data from SQL database. Could anyone please explain in VB.net with a small example from database connection to databinding and retreiving the data in web application
|
|
|
|
|
This is an absolute beginner question - you should try reading the site at large and/or MSDN before asking a question like this. There is tons of info online.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I guess time matters. There are only code snippets on simple data binding but not in complex data binding. Because i was unable to find it i have asked this question.
|
|
|
|
|
OK, well, this is more detail than the original question. What do you mean by 'complex data binding' ? Have you followed any of the 'simple' examples on the web, to give you some idea of what you require ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
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.
|
|
|
|