|
gubba wrote: my question is that is there any method that we can retreive the values not using the colmn names but the column numbers.
I don't think so. You can define aliases for the columns though, e.g. SELECT Option_1 AS [1], Select Option_2 AS [2] etc...
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
i insert new row in sql server with this syntax
Dim insert_transaction As SqlCommand
insert_transaction = New SqlCommand("insert into Transaction (Transaction_Id,Account_Id,Type,Amount,Date,Time) values ('30','" & account & "','Account Transfer','" & money.Text & "','" & Today & "','" & time & "')", myConnection)
insert_transaction.ExecuteNonQuery()
the error appear in ExecuteNonQuery()
the question is
how i insert new row in vb.net connect with sql server ?
|
|
|
|
|
|
the error "Icorrect synyax near the keyword 'Transaction'" and i have table transaction in database
and anther question : how can insert primary key ( Transaction_Id) automatic without i insert it manual
|
|
|
|
|
declear the field Transaction_Id as identity and write the query with @@IDENTITY AS ID
like this
insert_transaction = New SqlCommand("insert into [Transaction] (Transaction_Id,Account_Id,Type,Amount,Date,Time) values ('30','" & account & "','Account Transfer','" & money.Text & "','" & Today & "','" & time & "') @@IDENTITY AS ID ", myConnection)
object autonumber = insert_transaction.ExecuteScalarIdentity()
|
|
|
|
|
1. new error appear :"there is no source code available for the current loaction
if i click yes the same last error appear"
2. and I'm not understand the how declare the @@IDENTITY , and if declare it there is no meaning for insert value for transaction_Id
|
|
|
|
|
|
Try it this way:
insert_transaction = New SqlCommand("insert into [Transaction] (Transaction_Id,Account_Id,Type,Amount,Date,Time) values ('30','" & account & "','Account Transfer','" & money.Text & "','" & Today & "','" & time & "')", myConnection)
The word Transaction has a special meaning to most databases.
Having said that, it would be a great deal better if you used parameters in your query, as your current query leaves your database open to SQL injection.
|
|
|
|
|
Hi All,
Is there any Query to Export Table to Xml File Using Sql Server?
Plz Suggest Me ...
Thx in Advance
Nagaraju
|
|
|
|
|
In MS SQL Server 2000 there is a "FOR" clause which you can use to retrive the select query result in xml. Basic syntax is as follows,
<br />
FOR XML mode [, XMLDATA] [, ELEMENTS][, BINARY BASE64]<br />
<br />
Arguments<br />
XML mode<br />
<br />
Specifies the XML mode. XML mode determines the shape of the resulting XML. <br />
mode can be RAW, AUTO, or EXPLICIT.<br />
<br />
XMLDATA<br />
<br />
Specifies that an XML-Data schema should be returned. The schema is prepended to the document as an inline schema.<br />
<br />
ELEMENTS<br />
<br />
If the ELEMENTS option is specified, the columns are returned as subelements. Otherwise, they are mapped to XML attributes. This option is supported in AUTO mode only.<br />
<br />
BINARY BASE64<br />
<br />
If the BINARY Base64 option is specified, any binary data returned by the query is represented in base64-encoded format. To retrieve binary data using RAW and EXPLICIT mode, this option must be specified. In AUTO mode, binary data is returned as a reference by default.<br />
Example : Select * from TableName for xml auto
You can search the SQL transact help for further details.
Nothing is Impossible. Even impossible spells "i m possible"
|
|
|
|
|
Thanks Maharishi,
But I need to Save the whole table Data into a xml file which is to be created with a sql query.
means
Select * from TableName to "c:\test.xml"
I need a query to send whole sql table to cml file
is there any way to do like that?
thx..........
Nagaraju
|
|
|
|
|
I don't know wether you can achieve this with a sql statement, but if your're using a .NET-application , to send the SQL Statement, you could do the following:
- Fill a DataSet via SqlDataAdapter with the output of your Select-statement
- Write the data to a xml-file using the DataSet.WriteXML()-method.
This would solve your problem in a very easy way, but if you really need to do that in one sql-statement I haven't got the faintest idea.
Tobias
|
|
|
|
|
Hi,
For that you will need to write a PL/SQL for this kind of stuff. In MS SQL 2000/2005 there is an extended stored proc named xp_cmdshell which can be used to access the windows command line which can be used to save file. I have got an example which you can use for this...
DECLARE @FileName varchar(50),
@bcpCommand varchar(2000)
SET @FileName = 'c:\data.txt'
SET @bcpCommand = 'bcp "SELECT * FROM TableName for xml auto" queryout "'
SET @bcpCommand = @bcpCommand + @FileName + '" -U sa -P pwd -c'
EXEC master..xp_cmdshell @bcpCommand
But for this kind of extended proc access the procedure has to run in 'sa' context... or you need administrator rights to do that...
Hope this helps
Maharishi
Nothing is Impossible. Even impossible spells "i m possible"
|
|
|
|
|
I want to connect to a database and retrieve and insert data which is in another server.which means the database is not in our server.
it may be in another server globally remote.
this is about an asp web application.
please reply me as soon as possible
dayya <gmherath@gmail.com>
|
|
|
|
|
Either set your remote server up as a linked server in SQL Server or write a web service to access it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
dayya wrote: please reply me as soon as possible
What kind of reply are you looking for? Suggestions or free code?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
How can we get the newly inserted row's size from a SQL Server table?
Soumya Mathew
|
|
|
|
|
Soumya Mathew wrote: How can we get the newly inserted row's size from a SQL Server table?
I really have no clue what you mean by "Row Size"...
Are you trying to say you want the sum of individual field sizes?
|
|
|
|
|
Don't you mean the row count ???
<br />
select count(*) from tablename<br />
|
|
|
|
|
hi all,
i have developed an application in vb.net using Ms-Sql as back end.
the application is a multiuser on net/Lan.
But i have no idea if more than one user fire same querry at the same time.
is this hang the system/application.
if so solution please
thankx in advance.
-- modified at 4:43 Thursday 29th November, 2007
rmshah
Developer
|
|
|
|
|
r_mohd wrote: But i have no idea if more than one user fire same querry at the same time.
is this hang the system or crash the application.
SQL Server is designed as a scalable back-end database for multi-user applications. As long as you write your data access code and queries in an efficient manner, you should have no problems.
r_mohd wrote: pl remdy also
What does this mean? Please try and use English - textspeak is really annoying.
BTW, you claim to be a Senior Developer but you don't have basic knowledge of data access? I find this very worrying .
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: BTW, you claim to be a Senior Developer but you don't have basic knowledge of data access? I find this very worrying
The "Senior" is probably not an adjective for the "Developer"
|
|
|
|
|
He's now modified his post and changed his job title to 'Developer'. I wonder whether he got demoted after I posted my comments?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: He's now modified his post and changed his job title to 'Developer'. I wonder whether he got demoted after I posted my comments?
|
|
|
|
|
Hi all,
I need to be able to read in a CSV and then write all data back to a specified table within Oracle.
At the moment, I have put the following Oracle connection together, but need to read in c:\test.csv for example.
OracleConnection importOraConn = new OracleConnection();
importOraConn.ConnectionString = "User Id=USERNAME,Password=PASSWORD;Data Source=ORACLEDB";
importOraConn.Open();
OracleCommand importOraCommand = importOraConn.CreateCommand();
OracleDataAdapter oda = new OracleDataAdapter(importOraCommand);
Any help with this would be greatly appreciated.
Thanks
|
|
|
|