|
how to get name of the file before extention from database..
|
|
|
|
|
Do you mean a database file or just a string that contains a filename.
To remove the path and the extension, you could try something like:
declare @filename varchar(50);
set @filename = 'c:\a\b\c\filename.extension';
set @filename = substring( @filename, 1, charindex( '.', @filename) - 1)
while charindex( '\', @filename) > 0
begin
set @filename = substring( @filename, charindex( '\', @filename) + 1, 999999)
end
select @filename
And if you're interested in files of a database you should have a look at sys.database_files[^]
|
|
|
|
|
hi,
Which system table in the MS sql hold the information about the user created tables?
regards,
Bill
|
|
|
|
|
Hi,
It depends on what information you're looking for and what version of SQL Server you're using. If you're using 2005 or higher, you could use:
select * from sys.tables
|
|
|
|
|
Hi
I developing a Emplyee Scheduler I need to display weekly Schedule of every Employee in a Single row but I am get records in columns (verticly)
just need to display them like Whole week record in fornt of name of employee. I am using ASP.NET and C# .... can any help its urgent
|
|
|
|
|
Without knowing anything more of your query (or about the data) it's quite impossible to say what's the problem. You could have a look at Using PIVOT and UNPIVOT[^]. Perhaps it is what you're looking for.
|
|
|
|
|
thanx but i am using SQL 2000,let me make u littel bit clear i am getting records like
name1 - date1 - Schedule
name2 - date2 - Schedule
name1 - date1 - Schedule
name2 - date2 - Schedule
and I want or display
------- - date1 - date2
name1 - Schedule - Schedule
name2 - Schedule - Schedule
I hope you and understand and help me
modified on Thursday, February 26, 2009 2:21 PM
|
|
|
|
|
Hi,
I am using dataset to update/insert the data in the database. Whenever its about to update the dataset, it gives me the following error:
"OleDbCommand.Prepare method requires all parameters to have an explicitly set type."
Can somebody please help me with this problem?
Here is my code:
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
{
try
{
conn.Open();
OleDbCommand selectCmd = new OleDbCommand("select * from tableA where col1=? and col2=?", conn);
selectCmd.Parameters.AddWithValue("@col1", val1);
selectCmd.Parameters.AddWithValue("@col2", val2);
OleDbDataAdapter adapter = new OleDbDataAdapter(selectCmd);
OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);
DataSet selectDS = new DataSet();
adapter.Fill(selectDS, "TableA");
DataTable table = selectDS.Tables["TableA"];
DataRow row = null;
int mode = 0;
if (table.Rows.Count > 0)
{
row = table.Rows[0];
mode = 1;
}
else
{
row = table.NewRow();
}
row["col1"] = val1;
row["col2"] = val2;
row["col3"] = val3;
if (mode == 0)
{
table.Rows.Add(row);
}
adapter.Update(selectDS, "TableA");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}
}
Thank you,
Prateek
|
|
|
|
|
Explicitly and fully define each parameter. Personally, I think it is poor practice to allow a DB to infer such information when it is known ahead of time. It is fairly simple and will reflect well on the continued maintenance of your system. And as a bonus it will eliminate errors such as this from your code.
|
|
|
|
|
Thanks, I'll keep that in mind.
|
|
|
|
|
I agree with Ennis that it's a 'bad' practice to let the autogeneration to create the statements. But if you want to use it, there are two conditions you must meet:
- you must use command builder when select statement is created
- there must be a key column present in the dataset
I think it's the later that may be causing problems. Another possible cause may be column names that contain illegal characters or reserved words. So you should check if for example UpådateCommand is generated correctly.
More info: Generating Commands with CommandBuilders (ADO.NET)[^]
|
|
|
|
|
Dear Friend's
I have an application for Finance Management which created using Visual Studio 2005 for frontend using c# language and sql server 2005 as backend, in this system i use float datatype for storing all amount, but now it's giving me lots of calculation error because of roundup and other things, so our team plan to convert datatype float to decimal, is this ok or should we plan something else??
And if the changing datatype decision is ok then can you give me easiest way to change the datatype in one shot for all table from my database....
thanks and regard's
Sasmi
|
|
|
|
|
It really depends on how much precision you need. Oh and if you deal in Indonesian Baht. Also make sure you are not dealing with the Zimbabwe currency, you will run out of zeros very fast.
I work in a finanacial instution and we use decimal 38,6 for all our calcs. We had 38,10 for a while but were getting stray 1 in the 9th decimal position for some reason. Changing to 6 decimal places fixed a lot of issues for us.
Also you cannot convert from e number direct to decimal, you have to go through float first.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
thanks for your reply
Sasmi
|
|
|
|
|
Just as a side point to this, we've used decimal thoughout our database and personally I think its massive overkill. If you are losing precision with a float, then fair enough but high precision decimals take a whopping 17 bytes of space as opposed to your 4 for a float.
In our case, everything fits fine into a float, so the other 13 bytes are just pure overhead. No wonder the database is the size of Belgium.
Regards,
Rob Philpott.
|
|
|
|
|
So,
If you remove the overhead from Belgium, Belgium will float?
Wout Louwers
|
|
|
|
|
Well, that's not quite what I meant, but probably...
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: No wonder the database is the size of Belgium.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
And here I thought I was the only one that cared about database size.
|
|
|
|
|
when i open tables from sql server management studio i have on
Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum) The system cannot find the file specified. (Exception from HRESULT: 0x80070002) (Microsoft.SqlServer.ConnectionInfo)
|
|
|
|
|
Have you recently installed SQL Server 2008 Beta or any variant? Can you access the tables from a query?
I don't speak Idiot - please talk slowly and clearly
I don't know what all the fuss is about with America getting it's first black president. Zimbabwe's had one for years and he's sh*t. - Percy Drake , Shrewsbury
|
|
|
|
|
I CAN NOT ACCESS THE TABLES FROM QUERY ,CAN NOT ACCESS TABLES ,VIEWS AND STORED PROCEDURES
I CAN NOT CREATE NEW DATABASE ...
|
|
|
|
|
Suppose I have a table tblEmpStop
EmpID Date Reason
--------------------------------------------
1 01/01/2009 Fi
2 03/01/2009 Rs
3 03/01/2009 TS
I want to make a view/query which take from tblEmpStop n replace in Coluem Reason
EmpID Date Reason
--------------------------------------------
1 01/01/2009 Fired
2 03/01/2009 Resigned
3 03/01/2009 Temporary Stop
I use Ms SQL Server 2000 with source code:
SELECT EmpID, [Date], IF Reason = Fi, Fire; elseif Reason = Rt, Retired; elseif Reason = Rs, Resigned AS ReasonStop
FROM dbo.tblEmpStop
but it did not work...
How can i do what i want above ?
Thanks you before hand
Best regard,
Sovann
VB.Net
|
|
|
|
|
Its easiest to use CASE[^]. So your query would be like:
SELECT EmpID,
[Date],
CASE Reason
WHEN 'Fi' THEN 'Fire'
WHEN 'Rt' THEN 'Retired'
...
END AS Reason
FROM dbo.tblEmpStop
|
|
|
|
|
Thanks your for your help.
But when i run it show message like:
The Query Designer does not support the CASE SQL construct.
But it was work...
Thanks you again..
VB.Net
|
|
|
|