|
nothingbutcat wrote: [SqlException: SQL Server does not exist or access denied.]
Well, either you are attempting to connect to a SQL Server that does not exist. Or the SQL Server does exist but you don't have the authority to use it from an ASP.NET application.
Check your connection string. Does the server exist?
Are you using a trusted connection?
* If yes, does SQL Server permit access to the ASP.NET account?
* If no, have you set up the relevant user in SQL Server? And Is the password specified in the connection string correct?
|
|
|
|
|
Thank you. It's helpful.
It is our attitude towards life and work that makes our life 100%
|
|
|
|
|
Hi Everyone!
Is there any way by which I can convert .NET Framework types to SQL data type to be used by a Create Table command?
Some code to explain what I intend to do:
<code>public class SqlTableAdapter<T> where T : new()
...
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
for (int indexProperty = 0; indexProperty < properties.Length; indexProperty++)
{
Object[] attributes = properties[indexProperty].GetCustomAttributes(typeof(DataObjectFieldAttribute), true);
if (attributes.Length > 0)
{
DataObjectFieldAttribute dataObjectField = attributes[0] as DataObjectFieldAttribute;
DataColumn dataColumn = new DataColumn(properties[indexProperty].Name, properties[indexProperty].PropertyType);
dataColumn.Unique = dataObjectField.IsIdentity;
dataColumn.AllowDBNull = dataObjectField.IsNullable;
if (properties[indexProperty].PropertyType == typeof(string))
{
dataColumn.MaxLength = dataObjectField.Length;
}
dataColumn.SqlType = SqlTypeConvert( properties[indexProperty].PropertyType );
dataColumns.Add(dataColumn);
}
}
...
...
DbCommand commandCreateTable = this.Connection.CreateCommand();
commandCreateTable.Connection = this.Connection;
commandCreateTable.CommandText = string.Format("CREATE TABLE [{0}] ({1})", typeof(T).ToString(), columnDefinition);
commandCreateTable.CommandType = CommandType.Text;
Thanks in advanced for your help
Gywox
-- modified at 10:29 Thursday 29th March, 2007
|
|
|
|
|
i have a column named ReceiveDate..that is nvarchar.and have a row '27/03/2007'
when i run this statement that have some problems:
select * from tablea where
convert(datetime,OrderDate,101) >= (CONVERT(datetime,'26/03/2006',101)) AND
convert(datetime,OrderDate,101) <= (CONVERT(datetime,'27/04/2007',101))
pls any body can halp me?if possible give the correct select statement here.
thanks.
|
|
|
|
|
Test270307 wrote: when i run this statement that have some problems
That's a bit vague. What sort of problems?
Test270307 wrote: select * from tablea where
convert(datetime,OrderDate,101) >= (CONVERT(datetime,'26/03/2006',101)) AND
convert(datetime,OrderDate,101) <= (CONVERT(datetime,'27/04/2007',101))
Why are you doing all these conversions?
SELECT *
FROM TableA
WHERE OrderDate >= '2006-03-26'
AND OrderDate <= '2007-04-27'
When writing a date in SQL always use ISO format. That way you don't have to worry about cultural differences and your code will work anywhere.
|
|
|
|
|
sorry dear,
ur select statement does not return any rows.
in my select statement problems was:
"The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value."
|
|
|
|
|
Test270307 wrote: ur select statement does not return any rows
Then perhaps OrderDate was in an incorrect type. If you are going to store dates in the database then store them as a SMALLDATETIME or a DATETIME . Do not store them as anything else unless you have an exceptionally good reason.
|
|
|
|
|
convert function's style 101 represents mm/dd/yy
your dates are in the format dd/mm/yyyy
use 103 for the same like ....
select * from tablea where
convert(datetime,OrderDate,103) >= (CONVERT(datetime,'26/03/2006',103)) AND
convert(datetime,OrderDate,103) <= (CONVERT(datetime,'27/04/2007',103))
Regards
KP
|
|
|
|
|
|
1
101
U.S.
mm/dd/yyyy
2
102
ANSI
yy.mm.dd
3
103
British/French
dd/mm/yy
Best Regards,
Chetan Patel
|
|
|
|
|
When you try to start Enterprise Manager of SQL server 2000, you get the following error message:
Snap-in failed to initialize.
Name: Not available
CLSID: {A841B6C2-7577-11D0-BB1F-00A0C922E79C}.
Earlier it was running perfectly alright. but for installing report service feature i upgrade sql2000 with service pack 3. after running setupsql.exe . it was shwing message like you should now backup your master and msdb database since this installation has update their content.
please help
thanks
regards
imran khan
|
|
|
|
|
Hi all,
How to delete duplicate Records in a table in SQLSERVER.
|
|
|
|
|
hi,
suppose col001 of table1 is the duplicated values.then the query
"select col001 from table1 group by col001 having count(col001)>1" will get all the
duplicate values so,
the below query will delete all the duplicated records.
"delete from table1
where col001 in (
select col001 from table1 group by col001 having count(col001)>1)"
regards
Jijo
jijo jose
|
|
|
|
|
Hi jijo jose,
Thanks for your response, but your solution deletes all records which are duplicate.even table does n't contain one value.
i want only delete duplicated records other than first value'
ex:
Sample Table Contains records are
sno sname
10 XXX
10 XXX
10 XXX
20 YYY
20 YYY
But after deletion of duplicate records i want records in table like this : sno sname
10 XXX
20 YYY
|
|
|
|
|
in continuation to my earlier solution....
select * from tblA where newcol IN (select min(newcol) from tblA group by sno having count(*) > 1)
should give first occurance of the each duplicate row.
Note :
newcol is the new identity colum
Regards
KP
|
|
|
|
|
hi,
I thought, you wanted to delete all the dubplicated one including original,
Then do this in your query analyser.........
1 st step
----------
alter table table1 add [id] int identity
2nd step
----------
delete from table1
where [id]
not in
(select min([id]) from table1 group by col001)
it will delete all the duplicate records from table1
regards
Jijo
-- modified at 9:36 Thursday 29th March, 2007
jijo jose
|
|
|
|
|
Add new column to the table and make it IDENTITY
so that each row can be identified Uniquely.
Regards
KP
|
|
|
|
|
You can use the temp table, put the only exist records into the temp table then you can delete the original table's records use the condition with the information of the temp table.
onestone
|
|
|
|
|
I have write a Strore Procedure with Encryption.
for Exmaple
alter Proc GetAll
with encryption
as
select * from test1
after completing SP Encryption.
I am not able to again modify My Store Procedure.
please help me.
Pavan Pareta
|
|
|
|
|
|
|
This is the accepted wisdom, but as with a lot of things that are accepted wisdom, it's not always true. Take a quick search on Google for decrypt Sql Server procedure, and you get numerous hits - some of which tell you how to decrypt procs. I've provided a link to one above.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I have a table with a parent-child relationship in a MySQL database:
id
parent_id - points to id
other columns
I can easily extract all rows belonging to a particular parent. For example:
SELECT * FROM table WHERE parent_id=5
What I'm trying to do is extend this to not only get all rows belonging to a particular parent, but also get a count of each row's children (the grandchildren). I don't need any further generations. Other than retrieving the children and iterating through the rows and fetching the counts seperatley, I've been getting into a good muddle with joins and self-referential joins.
I'm hoping that some kind soul has a few suggestions!
|
|
|
|
|
This seems to work on my system (not MySQL).
SELECT * , (SELECT COUNT(*) FROM tblTasks WHERE parentTaskID=T.taskID)
FROM tblTasks AS T
WHERE T.parentTaskID=5;
Don't know whether MySQL will support the (SELECT ...).
Hope this helps.
|
|
|
|
|
That is perfect, thank you! And a whole lot simpler than my left joins
|
|
|
|