|
Hi,
I have a simple method that checks if a sheet name is present in the excel file or not. The code is simple and works fine when the sheet name doesn't contain any spaces:
private bool validateExcelSheetByName(string name, OleDbConnection connection) {
bool result = true;
try {
if (connection.State == ConnectionState.Closed)
connection.Open();
var command = new OleDbCommand(string.Format("select * from [{0}]", name), connection);
command.ExecuteNonQuery();
}
catch {
result = false;
if (connection.State == ConnectionState.Open)
connection.Close();
}
return result;
}
In case I have any space in the sheet name (for example 'My Sheet'), I get an exception saying:
Invalid bracketing of name 'My Sheet$'.
I store the sheet name in a variable:
private const string sheetName = "My Sheet$";
How can I fix this code so it will work when I have spaces in the sheet name?
Thank you!
Andrei
------------
Croitoriu Andrei
andrei.croitoriu@gmail.com
http://www.stud.usv.ro/~acroitoriu
http://spaces.msn.com/acroitoriu/
"No complexity beyond what is necessary"
|
|
|
|
|
I by mistake copied another declaration of a sheet in my file. The above code fails when the sheet name is something like:
private const string sheetName = "My. Sheet$";
So in case the name contains a dot and a space the exception will be thrown.
How can I fix this?
Thank you!
------------
Croitoriu Andrei
andrei.croitoriu@gmail.com
http://www.stud.usv.ro/~acroitoriu
http://spaces.msn.com/acroitoriu/
"No complexity beyond what is necessary"
|
|
|
|
|
Hi i am facing problem in nested cursor...,
In this first cursor for managers and second one is for employee details...,
Its going on well..,
But the employee detail it binding the all the managers, last record of employee at 2 times...,
but i want to bind those also at one time...,
See i given my procedure on down side:
pLz tell me what wrong in that?,
DECLARE curMgr CURSOR FOR
SELECT distinct ManagerID FROM @tbl_TempManagers
OPEN curMgr
FETCH NEXT FROM curMgr INTO @mgID
Insert Into @tbl_TempEmployee Select MId,ID,UserName,EId from tbl_login Where Mid=@mgid
WHILE (@@FETCH_STATUS = 0 )
BEGIN
SET @EmpDetail = ''
SELECT @Count=Count(*) FROM @tbl_TempEmployee
--
SET @Counter=1
DECLARE curDetailList CURSOR FOR
SELECT distinct EmployeeName from @tbl_Tempemployee where ManagerId = @mgID
OPEN curDetailList
FETCH NEXT FROM curDetailList INTO @EmployeeName1
SELECT
convert(varchar(20),TSDate,101) as [Date],TSSubject as [Subject],TSDescription as [Description],
TSHour as [Hour],TSMin as [Minute],convert(varchar(20),CreationDate,101) as [Creation Date],
CreationBy as [Name Of Employee] FROM tbl_TSEnterData where CreationBy=@employeename1
AND TSDate BETWEEN
CONVERT( NVARCHAR, DATEADD(wk, -1, @d) , 101) AND CONVERT( NVARCHAR, DATEADD(dd, -1, @d) , 101)
order by CreationBy asc,TSDate Desc
WHILE (@@FETCH_STATUS = 0 AND @Counter<@Count)
BEGIN
SET @EmpDetail = @EmpDetail + @EmployeeName1 + ', '
FETCH NEXT FROM curDetailList INTO @EmployeeName1
SELECT
convert(varchar(20),TSDate,101) as [Date],TSSubject as [Subject],TSDescription as [Description],
TSHour as [Hour],TSMin as [Minute],convert(varchar(20),CreationDate,101) as [Creation Date],
CreationBy as [Name Of Employee] FROM tbl_TSEnterData where CreationBy=@employeename1
AND TSDate BETWEEN
CONVERT( NVARCHAR, DATEADD(wk, -1, @d) , 101) AND CONVERT( NVARCHAR, DATEADD(dd, -1, @d) , 101)
order by CreationBy asc,TSDate Desc
SET @counter=@counter+1
END
CLOSE curDetailList
DEALLOCATE curDetailList
INSERT INTO @Result VALUES (@mgID, @EmpDetail)
FETCH NEXT FROM curmgr INTO @mgID
Insert Into @tbl_TempEmployee Select MId,ID,UserName,EId from tbl_login Where Mid=@mgid
END
CLOSE curmgr
DEALLOCATE curmgr
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
modified on Wednesday, July 16, 2008 2:52 AM
|
|
|
|
|
I have trouble understanding your question so I can't provide much actual help; however looking at the query one thing puzzles me.
Why do you have similar selects both outside your "WHILE" loops as well as inside? To me it looks like it will cause problems with the loop over FETCH NEXT.
Removing duplicate functionality could help you reduce the complexity of your query making it more manageable, and it could possible be from those double selects that your problems arise.
|
|
|
|
|
hi
m trying ot retrieve bytes stored in sql table....
these bytes represent the image....
i have tried but only first 13 bytes are retrived..
how can i retrieve all the bytes???
|
|
|
|
|
How are the information stored?
|
|
|
|
|
hi,
How do i convert a varchar field into the datetime data type? the reason i need this lies in the requirement that in the earlier data base the column that is holding the date value is having the data type as varchar. and in the new design the column data type is datetime. How i transfer old Data to new column without loss .from the older design to the newer and got stuck with this datetime convertion issue. do let me know the best possible solution.iam using sql server 2000
following are the sample date Format that is there in the older table for the date.
dd/mm/yyyy.
Regards
Rameez
|
|
|
|
|
Try:
Convert(DATETIME, 'your datestring in dd/mm/yyyy format here', 103)
|
|
|
|
|
Hi everyone, i was creating a stand alone application i.e. a project using Visual Studio 2005 with C#.NET. After creating six different GUI which links to each other, and also created datatable for each and everyone of the GUI. I started encountered problems interacting to each database.For instance on this application, i want my first page which required the Username and password before connecting to the next page. I want this username and password to be part of data inserted in the database table or else error message should display. Just like signing to codeproject account. And again, i want to assign one person as an administrator who will be given people access to the said application.
Secondly,after the necessary update on this application, i want my result to be displaying at the front-end i.e. after connecting a screen to the management pc.
I would be much more appreciate your concern about this, if anyone could help me out. I shall be waiting for your solution on this.
Cheers
|
|
|
|
|
So what exactly is your problem, which bit is not working? Post your code so we can try to help.
I suspect you have not really thought about your database design?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hello all,
I may not posed the question in a manner by which I could get a decent search response, so here I am.
I am trying to figure out a way to connect a table to an ODBC datasource on my PC. To illustrate, in Access you can "Link" or "Import" data from an ODBC Source. I am wondering if you can do the same with SQL Server 2007.
Any responses shall be greatly appreciated.
Best regards,
F
|
|
|
|
|
Are there any alternatives to Database Publishing Wizard[^] that allow you to select which objects to script?
Also, any suggestions for tools that help with change management in SQL database development?
Todd Smith
|
|
|
|
|
|
Hi guys i having some probs ...,
Plz any one knows help me...,
On each monday one stored procedure have to run automatically...,
How can i do that?
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
you can use the SqlAgent to schedule jobs. Works a lot like windows task scheduler, just from enterpise manager/management studio.
|
|
|
|
|
Hi all ,
I am using ssrs2005.
I am trying to generate a report which list employee leave detail ie
Empcode , name , no of leave taken , balance leave. Now user want to see detail information of employee when he click on empcode .
Is it possible using ssrs2005.
I tried with subreport. How can I make subreport to be visible when he select particular employee code
Please help
imran khan
|
|
|
|
|
I would keep it simple and make two reports, and have your main one navigate to the detail report.
Add another report to the same project, and make sure you have a parameter for empcode.
In the first report (the main one), go to the properties for the empcode textbox. Under the Navigation tab, choose "Jump to report", then choose the detail report in the combo box. Click the "Parameters..." button and have empcode equal to "=ReportItems!empcode.Value" (I'm assuming that the textbox for empcode is called empcode).
When a user clicks on the empcode the detail report will show with the value that they clicked.
|
|
|
|
|
Is it possible to reset the identity column in Oracle? If possible, how? I've googled the query, but got the results only for Sql Server. Could any body please help.
Thanks in advance
meeram395
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
The last I knew, Oracle didn't have an identity column. Are you talking about resetting an Oracle Sequence? If so, here's an excerpt from the Oracle documentation:
#
To restart the sequence at a different number, you must drop and re-create it.
#
If you change the INCREMENT BY value before the first invocation of NEXTVAL, some sequence numbers will be skipped. Therefore, if you want to retain the original START WITH value, you must drop the sequence and re-create it with the original START WITH value and the new INCREMENT BY value.
#
Oracle Database performs some validations. For example, a new MAXVALUE cannot be imposed that is less than the current sequence number.
|
|
|
|
|
Hi All,
I have an install of SQL2005 in my server machine and I want to configure it so that I can connect to the server instance from another box via SQL Server Management Studio (SSMS). The following article is meant to provide me with a straigtforward step by step guide of doing this.
http://www.codeproject.com/KB/database/SQL_Server_2005_remote.aspx[^]
Although I've followed the instructions, I still can't connect remotely (I can connect using SSMS on the server machine, which means the problem is not with the service). Anyone can point me to some other resource? Could it be some other configuration outside of SQL?
Both machines are connected directly to the router (which is connected to the internet, not that it's relevant to the question at hand)
Thanks in advance.
----------------------------------------------------------
Every nation state's armed forces call themselves 'Defence',
makes me wonder why there are conflicts in the world.
|
|
|
|
|
Do you have any desktop firewalls installed which could be blocking the SQL Server traffic? By default, SQL Server listens on port 1433.
Tim
|
|
|
|
|
Hai to all,
I have already installed sqlserver 2000 in my windowsXP.Now i hae installed vs2003 and vs2005.
Presently working on vs2003 framework1.1 with sqlserver 2000.
I want to upgrade from vs2003 to vs2005 with sqlserver2005.
So is there any problem occrs if i install sqlserver2005 when sqlserver2000 already existed.
Tell me which type precautions i have to take before installation.
I want both versions of .net and sqlserver.
kissy
|
|
|
|
|
Kissy16 wrote: So is there any problem occrs if i install sqlserver2005 when sqlserver2000 already existed.
No problem. They can co-exist. However, each must have a unique name. There can be only one default (unnamed) instance.
|
|
|
|
|
Or you should be able to install SQL Server 2005 in place of (i believe it is called) SQL Server 2000.
|
|
|
|
|
I have a textbox called "textBox6.text" in a C# Windows Application in Visual Studio, and i want that the text entered by the user in the textbox should be added to the "PURPOSE" field in a table "TABLE2_HDB1" in Oracle database "HDB1" on clicking a "submit" button.
the coding for submit button is as follows:-
private void button1_Click(object sender, EventArgs e)
{
string OracleStmt;
string ConString;
OleDbConnection cn = null;
OleDbCommand cmd = null;
try
{
OracleStmt = "insert into TABLE2_HDB1(PURPOSE) values(@PURPOSE)";
ConString = " Provider=MSDAORA;Data Source=HDb1;User Id=SYSTEM
;Password=*****;";
cn = new OleDbConnection(ConString);
cmd = new OleDbCommand(OracleStmt, cn);
cmd.Parameters.Add(new OleDbParameter("@PURPOSE", OleDbType.VarChar , 20));
cmd.Parameters["@PURPOSE"].Value = textBox6.Text;
cn.Open();
cmd.ExecuteNonQuery();
textBox8 .Text = "record inserted successfully";
}
catch (Exception ex)
{
textBox8 .Text = ex.Message;
}
finally
{
cn.Close();
}
}
on executing this code u get the error :-
ORA-00936:missing expression
plz. help
|
|
|
|
|