|
Hi try the folllowing code.........
string sFilePath;//path of the file
string[] sSeperate;//get the exact name of file without extension
int iarrLength;//get the exact name of file without extension;resets the count
string sExtension;//get the extension of the file.
sFilePath = FileName;
sSeperate = sFilePath.Split('.');
iarrLength = sSeperate.Length - 1;
sExtension = sSeperate[iarrLength].ToString().ToUpper();
if (sExtension.ToUpper().Equals("XLS"))
{
//put your code here
}
else
{
MessageBox.Show("Invalid file selected!");
}
Warm Regards.........
NB:Please score if it is worth.........
Sebastian
|
|
|
|
|
IMO that would be insufficient: it sets a filter on what is initially shown, but not on
what is selectable.
Example: start with some filer, type *.* in the textbox for filename, click the open button,
it will now show all files in that folder, select a file, click open again; not that file
is selected, whether it fits the original filter or not.
So you should check afterwards as Sebastian indicated.
|
|
|
|
|
Hi there,
Is there a way to determinate the cursor type of a recordset using the .Execute command of a ADODB.Command object? If you use a ADODB.Recordset object, you define the cursor type like this:
myRecordset.Open mySQLCommand, myDatabase, adOpenKeyset
I now use stored procedures in my DB and I still want to set the cursor type to OpenKeyset, if that is possible...
Thanks, Werries
A programmer's life is good... or is it?? Ek dink nie so nie!
|
|
|
|
|
The cursor type won't change. Your SQL is still returning that same recrodset no matter if it's done by stored proc or by a SQL statement you pass in.
|
|
|
|
|
i have some errors while implementing stored procedure for sql server 2005 in my web form which i have design using vb dot net 2005. my code is like this:
i have made stored procedure like this:
ALTER PROCEDURE UpdateMemberInfo
@FName varchar(50),
@LName varchar(50),
@Password varchar(50),
@MemberName varchar(50)
AS
update T_Members set FirstName = @FName,LastName = @LName ,Password = @Password where MemberName = @MemberName
RETURN
Now i have to call this stored procedure in the click event of the button. So, i put the code like this in the button:
co.startconn()
cmd = New SqlCommand("UpdateMemberInfo", co.oConn)
cmd.CommandType = Data.CommandType.StoredProcedure
Try
para = New SqlParameter("@FName", fname)
cmd.Parameters.Add(para)
para = New SqlParameter("@LName", lname)
cmd.Parameters.Add(para)
para = New SqlParameter("@Password", pass)
cmd.Parameters.Add(para)
Catch
Response.Write(Err.Description)
End Try
Try
cmd.ExecuteNonQuery()
Catch
Response.Write(Err.Description)
End Try
But still there is error like this:
Procedure or function 'UpdateMemberInfo' expects parameter '@FName', which was not supplied.
suchitamanandhar@hotmail.com
|
|
|
|
|
It looks like you forgot to add the @membername parameter before calling your stored procedure.
Ben
|
|
|
|
|
You didn't supply any datatypes for these parameters, essentially letting the Parameters objects "guess" at what they are supposed to be. Be specific in your parameter declarations:
cmd.Parameters.Add(New SqlParameter("@FName", SqlDbType.VarChar, 50)).Value = fname
On top of that, you also didn't supply the @MemberName parameter.
|
|
|
|
|
Hi,
I have been struggeling to find a good way to merge my two collections.
The collections that is to be merged contains "From Time and To Time".
FIRST COLLECTION:
0700-1200
1200-1700
SECOND COLLECTION:
1100-1200
1300-1500
RESULT COLLECTION:
0700-1100
1100-1200
1200-1300
1300-1500
1500-1700
The second time the procedure is visited the first collection is like the result, and I only want to verify that the second collection is still correct merged with the first.
The procedure i made is complex and almost impossible to debug, and not reliable.
So please, please, can someone help me out here?
Regards
Svein Thomas
|
|
|
|
|
You don't mention anything about how your storing this data?? What kind of collection?? Is this a custom collection implementation?? How is the data represented??
|
|
|
|
|
I'll talk about the algorithm, but not the implementation:
I assume the second collection must lie "inside" the first (as in "opening hours" and
"actual appointments")
each collection holds what I will call nodes;
each node has a starting time ST and en ending time ET
now compare one node of one collection (say N1) with one node of another collection (say N2);
there either is or isnt an overlap; if there is no overlap, nothing needs to be done.
if there is an overlap between N1 and N2, there are three possible outcomes:
1. N1 remains as is (because N2 is equal to it, hence ST1=ST2 and ET1=ET2)
2. N1 is split two-ways because either ST1=ST2 or ET1=ET2 but not both
3. N1 is split three-ways because both ST1<>ST2 and ET1<>ET2
If we turn this inside out, we must make two tests to find out which case is ours,
then act accordingly.
So a brute force approach would be to apply the above to any combination of
"a node from collection 1" and "a node from collection 2"
Of course we could optimize this by:
- keeping nodes in chronological order
- then for each node in collection 2 search which node in collection 1 matches, and
do the three-way test as before
I leave everything else to you !
|
|
|
|
|
i have made this sql statement and it works well but sometimes it show the result and sometimes not
this sql statement between two datepicker
it works with some date and the other no
and sometime it gives error (out of range date)
here is my code
cmd.CommandText = "select sum(fatrq1)reglz from reglz where fatrdate between '" + DateTimePicker1.Value + "'and'" + DateTimePicker2.Value + "'"<br />
'fatrq1<br />
dr = cmd.ExecuteReader<br />
when i want to put these dates it doesn't works (from 1/1/2007 To 1/7/2007)
it may work if i enter another dates
what ca i do ??
|
|
|
|
|
|
after editing my code like that
Dim x, y As String<br />
x = DateTimePicker1.Value<br />
y = DateTimePicker2.Value<br />
<br />
<br />
<br />
<br />
cmd.CommandText = "select sum(fatrq1)reglz, convert(varchar,fatrdate,101) from reglz where fatrdate between '" + x + "'and'" + y + "'"<br />
dr = cmd.ExecuteReader<br />
the vb gives me error
Column 'reglz.fatrdate' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.
|
|
|
|
|
Use a parameterize query string to do this and you won't have to worry about what format the dates and times show up in in your string. The method that you used resulted in a string like this:
....WHERE fatrdate BETWEEN '#7/25/2007 12:24:31 PM#'and'...
which SQL Server doesn't like.
Read Colin Angus Mackay's article on SQL Injection Attacks[^] and you'll find out why what you're doing doesn't work and how dangerous it is.
|
|
|
|
|
i want to pass two sting parameters in crystal report to run the query
SELECT * FROM xyz WHERE abc BETWEEN 'parameter1' AND 'parameter2'
i want to write the code on form which have crystal report viewer but i have no idea, i also searched on internet but that was not helpfull. anybody can give me code that will work than i will be your thankful.
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
|
Hi,
Is there any way to convert an HTML document to an image file (jpg, tiff, bmp...anyone of them) without taking a screen shot? I've been looking up the IHTMLElementRender object and its DrawToDC method. Would there be any way to use it for this? Or any other method?
Thanks,
Ahmad
|
|
|
|
|
i want my dialogboxes to appear as win-vista dialogboxes? can i do it in vb.net? how can i change the font size/face in a "msgbox"???
(Jameel)
|
|
|
|
|
jamilkhan007 wrote: how can i change the font size/face in a "msgbox"???
You can't. You have no control over the appearance of the built-in MessageBox. You'll have to write your own MessageBox class if you want this kind of control.
|
|
|
|
|
when i apply fonts to unicode language "Urdu" in a rich text box in vb.net, the urdu-fonts dont work at all, i have installed them properly bt.....
(Jameel)
|
|
|
|
|
Hey,
I am trying to capture a screen shot of a form that is in the background. I donot want to display it to the user. I am doing the following:
Dim Pic As Bitmap
Dim SS As Graphics
Pic = New Bitmap(Me.Width, Me.Height, Imaging.PixelFormat.Format32bppArgb)
SS = Graphics.FromImage(Pic)
SS.CopyFromScreen(Me.Location, New Point(0, 0), Me.Size, CopyPixelOperation.SourceCopy)
Pic.Save("C:\test.jpg", ImageFormat.Jpeg)
The problem is it takes a shot of the screen in the region specified excluding the form! This is even if I am displaying the form. Any suggestions?
Thanks
Ahmad
|
|
|
|
|
Ahmad Zaidi wrote: I am trying to capture a screen shot of a form that is in the background.
That's not possible.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Unfortunately you would have to flick to the other form, take the scrren shot then flick back to the original form...it will look annoying but it will achieve your goal. The way a screen displays things exists only on one layer. Although windows stack in many layers...there is no way of detirmining the pixel data from behind the current form because the entire screen image renders in only 2 dimensions.
|
|
|
|
|
Since the non-visible portions of a form are not painted, you'll be grabbing a screen shot of nothing.
|
|
|
|
|
Hi,
there is a different possibility combining the following ideas:
- Control.DrawToBitmap() captures a Control (a Form is a Control) and paints it again
into a bitmap; AFAIK it does not rely on the screen, on covered parts, Z-order and the like.
- if that were to leave out those parts that are covered by some other Window, you could
move the Form to a position "outside your monitor", say at (20000,20000)
Moving the form there will make DrawToBitmap() capture it all
- what remains to be solved now is to move the form back to its original position without
coming topmost; my first attempt would be to just restore its Location, and see what happens.
BTW: whatever the method for capturing the form, since it does not have focus, I expect
it to look a bit different (as compared to when you have the form active and in front of you).
Good luck.
If you try it, let us know the outcome !
|
|
|
|