|
Hi all,
I would like to know whether one uses the to_date function in a update statement aswell, as one would in a insert statement (when making use of a Oracle Database).
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
I make use of the 'to_date' function everywhere. Whether it's a 'select', 'insert', 'update' or even a 'delete' statement, you can use a function call just about anywhere.
Do you have a specific instance that is giving you an error or problem?
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Hello guys..
Looks like I just need a litle help on my SQL syntax in C#.NET
I have a field in my database which is DateTime type. Looks like I can't get the syntax right for comparing the value from the textBox with the field in database.
Now what I have looks like:
<br />
DateTime ShDate = DateTime.Parse(txtDate.Text);<br />
cmd1.CommandText = "SELECT ShipedDate FROM Details WHERE Details.ShipedDate = #ShDate#";<br />
When I fill dataset with the adapter which has this SelectCommand it will report error in date in the syntax expresion. Now the variable ShDate has a DateTime type in C# and it stores a date from the textbox with a help of conversion and it is in a correct format(I cheked while debuging).
I think the problem is somewhere here = #ShDate# . I bet I am missing some quotation marks ("") or single quote('').
So does any one have a clue?
Thanks..
|
|
|
|
|
Hi,
I think you are just now migrating from MS-Acccess.
When comparing date in SQL Server no need of "#".
Just simply " = ShDate " is enough.
Senthil
|
|
|
|
|
Can you try this out...
DateTime ShDate = DateTime.Parse(txtDate.Text);
cmd1.CommandText = 'SELECT ShipedDate FROM Details WHERE Details.ShipedDate =%' + ShDate + '%';
See if it helps.
Thanks!
Santhosh
Santhosh Kumar Edukulla
|
|
|
|
|
Apologies, ignore my previous post..
Try this
DateTime ShDate = DateTime.Parse(txtDate.Text);
cmd1.CommandText = 'SELECT ShipedDate FROM Details WHERE Details.ShipedDate like' + '''' + '%' + ShDate + '%' + '''';
I tried it on my sql box and it worked.
Hope this helps
Thanks!
Santhosh Kumar Edukulla
|
|
|
|
|
I'm looking to develop an application that will require a small database table structure (not more then 4-5 tables). I wanted to make the database internal to the application so that there wouldn't have to be a link out to a web server/SQL server anywhere, but with just receiving a new datafile to replace the old one, it would be able to pick it up. Is there any code/project type in Visual Studio that would allow me to create such a database that could be deployed with the application and be able to be queried with a SQL/Oracle type interface/query? I am open to writing the application in either Visual Basic or Visual C++.
|
|
|
|
|
|
I will look into it, but from a quick glance, it may just be that. Thank you very much.
|
|
|
|
|
Hi All
I Finished Deployment windows application and i will to setup it in the customer
My database is SqlSERVER 2005
I Used SqlServer EXPRESS 2005 to set the Backup of data base on it in the pc of customer
the Server is Mixed MOde
when I Running my Application The is give me this the Exeption
(An Erorr occurred while establishing aconnection to SQL Server 2005 , this failure may be caused by the fact that under the defult Settings SQL Server does not allow remote Connection (Provider :SQL Network Interface error :26-Error locating Server/Interface Specified))
what is the solve for this Problem ??
thanks for all Hellp me
Thaer
|
|
|
|
|
Hi Thaer Hamael
1- Go To Start -->Programs --> Microsoft SQL Server 2005 --> Configuration Tools
--> SQL Server 2005 Surface Area Configuration
2- collapse Analysis Service
3- Choice Local and remote Connection
4-Choice Database Engine and choice Remote connection Local and remote Connection and using both
Rami Abd Alhalim
|
|
|
|
|
i have to delete data but i have problem found relation between tables so i cant
delete data
how can delete data without drop relation ship between tables???
Rami Abd Alhalim
|
|
|
|
|
If I am understanding you correctly, you can not do this. That is the purpose of the foreign key constaint. It will not allow you to delete the data without dropping the relationship between the tables. The only other options is to delete data from all the tables in the correct sequence.
Hope that helps.
Ben
|
|
|
|
|
Thanks
how correct sequence
|
|
|
|
|
It depends on how your tables are related. Let's say you had:
ParentTable1
ChildTable1
ChildTable2
Both ChildTable1 and ChildTable2 have parenttable1ID which is the key. All of the records in childTable1 and childTable2 that have that parenttable1ID must be deleted before the record in ParentTable1 with parenttable1id can be deleted.
The benifit of this is that you can't orphen the Child table records. They must be deleted before the parent table record can be deleted.
Hope that helps.
Ben
|
|
|
|
|
set particular column's constraint as
Delete Rule as Set null
and
Update Rule as Set null
You can find this option where you define the relationship of tables. it is titled with "Insert and Update Specification" of sql server management studio.
divyesh
|
|
|
|
|
I need some help writing a stored proc. First, I am inserting a range of ZipCodes into a db, ZipBegin and ZipEnd(12345-12346). Although that seems relatively simple, however, I need to check those ranges and make sure that there is no other over lapping range.
for more clarity:
range A 12345-12346 is in the db
range B 12344-12347 is being inserted.
as you can see these ranges overlap, if that occurs I need to use a raiserror and rollback the transaction.
Does anyone have any suggestions on how I could do that?
|
|
|
|
|
What was wrong with my previous answer[^] to your question?
|
|
|
|
|
You want to check before or after inserting?
below logic will help you.
Before Inserting
------------------
check whether there is any ZIPCode exist within the range
sql
---
Select @begin = count(ZIPBegin) from tblZIPCodes where ZIPBegin between 12345 and 12346
Select @end = count(ZIPEnd) from tblZIPCodes where ZIPEnd between 12345 and 12346
If @begin > 0 or @end > 0
-- then there is an entry within that range already exist
else
--perform the insertion
After Inserting
----------------
BEGIN TRANSACTION
--Insert the records
-- then use the same sql stmt written above to get the value of @begin and
--@end
If @begin > 1 or @end > 1
-- multiple entries has been made
ROLLBACK TRANSACTION
RAISERROR
RETURN
else
--perform the insertion
COMMIT TRANSACTION
Regards John
|
|
|
|
|
I have a script of creating tables and stored procedure.
I want to check particular column is exists or not before dropping it or I just want to catch an exception while dropping particular column.
I cannot do so.
Thanks in advanced
Divyesh
|
|
|
|
|
Hi Mr. divyesh1432
this code to check if column exist or not
Exaple:
-------------------------------------------------------------
if exists(select column_name from information_schema.columns
where table_name='TableName' and column_name='ColumnName')
----------------------------------------------------------------------
Best regard
Rami Abd Alhalim
|
|
|
|
|
|
Mr. divyesh1432
if my answer correct plz tell me
thanks
Rami Abd Alhalim
|
|
|
|
|
|
in my application i use ado.net to connect the db and in ado.net when you connect the db it takes an instance of the relevant table and close the connection . but when the application runs it needs to access the db often and in order to do this do i have to connect the db each and every time the db is needed or keep the connection without closing . but the second option affects on concurrecy.
can you guys do some suggestions to this .
thank you ...
|
|
|
|