|
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;)
|
|
|
|
|
Use the DataFormattingExpression property. When you get your grid's properties, select your column and you should see an option. For example, you can use expressions like {0 }, {0:f}, and so on. A full list can be found: http://www.stevex.org/dottext/articles/158.aspx[^]
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
|
Hi all
I wonder if it is possible to get information about a specific SQL Server database? What I need is a way to get a list of all the tables in the database and also the names of all columns in all tables. I also need a way to get the datatype of each column.
Is this possible in SQL Server? (I am using MSDE)
|
|
|
|
|
Yes - the system tables (e.g. Sysobjects) hold details of the tables, views etc. and you can get the SQL of stored procedures and views from syscomments
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
SQL DMO is a great library for getting Sql Server metadata. See: http://www.sqlteam.com/item.asp?ItemID=9093[^].
It gives you a bit more flexibility than running queries like "select * from sysobjects where type='u'" and so on. It gives you a navigable heirarchy as well. You can get schema info using the .NET framework, but for what you're describing, I'd use DMO.
*->>Always working on my game, teach me
*->>something new.
cout << "dav1d\n";
|
|
|
|
|
True - but since most enterprise class database platforms have their own versions of the system tables you can wrte a plug-in based system that could be platform independent - rather like the Database Build Wizard[^]
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
Hi Everyone
Im a Beginner in using DTS
i want to make a package in SQL Server That execute an sql query:
- If this query returns rows, i want to take the first field for every row
and give it to a second job that execute another query using this field in a
loop until the number of fields ends
- And if this query doesent return any rows, i want to skip the others steps
that follow it
How Can I Do It????????
|
|
|
|
|
Hi Maro,
I came across an article today that might help you get started.
http://www.sqlteam.com/item.asp?ItemID=6881
The article was actually about trapping errors, but there are a couple of lines that may point you in the right direction:
Basically, try this:
declare @RC int
set @rc = 0
select Column1 from Table1
select @RC = @@ROWCOUNT
if @RC > 0
begin
{do the second job}
end
I realize this doesn't solve your entire problem, but I hope it at least points you in the right direction.
-DPR
|
|
|
|