|
CSV files are nothing but (C)omma (S)eperated (V)alues which you can edit in Excel application.
It is so simple to export a table to CSV file format. Read your table into a DataSet/DataReader.
create a text file with extenstion .csv using FileStream and write all your column values as comma seprated values..
Cheers,
Suresh
|
|
|
|
|
When creating methods that use GUID values as parameters, is it best to be passing type GUID, type String, or should I be creating a method for both?
Examples
1.
Public Sub New(id As Guid)
_id=id
End
Or
2.
Public Sub New(id As String)
_id=New Guid(id)
End
Or
3.
Public Sub New(id As String)
Me.New(New Guid(id))
End Sub
Public Sub New(id As Guid)
_id=id
End
Thanks in advance!
john miller
web developer
|
|
|
|
|
Probably number 3 since it gives you the greatest flexibility. It couldn't hurt in any case, but you might want to double check the value comming in as string and throw an exception if the format fails or if the Guide creation fails.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thanks for the feedback! I'm already validating the format, but I cut the code out for sake of the example. Much appreciated.
john miller
web developer
|
|
|
|
|
In my use of GUID's I always pass them as strings. It just makes life easier. Including the datatype I give them in the sql database. I am sure some would disagree with the approch, but it has worked well for me.
Ben
|
|
|
|
|
hi there,
i am working on a project that deals with access database. i need to convert .sql file to access file. unfortunetly i do not know sql queries. is there a program that converts .sql files to .mdb file or if someone has the code can u give it to me please.
signing off is preci
|
|
|
|
|
No, there isn't. An .SQL file is usually just a bunch of SQL statements that get executed by an SQL server against a database. Access doesn't know what to do with one of these files, and frankly, you're going to have a tough time getting this conversion to work. Access only understands a subset of SQL, not the entire TSQL language. If this SQL file isn't made specifically for an Access database, you're wasting your time making a conversion utility.
More than likely, that file is used for building an SQL Server database, for which there is the osql utility to execute the commands in the file.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi all,
I need a code to Dial a Phone Number using Visual Basic.I want to know what are the reuirements for this (libraries).This is very Urgent.
Thak U,
Rajeshwar
|
|
|
|
|
raju_reddy wrote: I need a code to Dial a Phone Number using Visual Basic.I want to know what are the reuirements for this (libraries).
This is entirely dependant on the ahrdware you have and what port it's connected to. Usually, this would require at least a modem connected to a serial port, so, Google for "VB6 serial comm" and you'll come up with all kinds of examples for serial communication. The command you send to the modem will probably be something like "ATDTphonenumber", but the exact format and options would be covered in the manual for the modem.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
It depends on the how you want to connect.
If you are using a PABX you need a TAPI driver from the vendor and make an application which instructs the TAPI driver.
I you are using only an analog line you indeed have to make something where a modem is also be involved.
Regards,
Bas
|
|
|
|
|
Hi
In the code below, I'm looping through all the items in dtPackBom2 and for each item I then loop through dtExclusions. If the item in dtPackBom2 exists in dtExclusions then I delete it from dtPackBom2.
What happens is that even though the loop is
For BomRow As Integer = 0 To Me.dtPackBom2.Rows.Count - 1
after you delete a row, I get an exception saying there is no row at position xxx. I then tried adding the row Me.dtPackBom2.AcceptChanges() after I delete a row, hoping that dtPackBom2.Rows.Count will now see the new reduced number of rows but I still get the same exception.
It seems to work if I put: If BomRow = Me.dtPackBom2.Rows.Count - 1 Then Exit For
For BomRow As Integer = 0 To Me.dtPackBom2.Rows.Count - 1
If BomRow = Me.dtPackBom2.Rows.Count - 1 Then Exit For
For i As Integer = 0 To Me.dtExclusions.Rows.Count - 1
If Me.dtPackBom2.Rows(BomRow).Item(2) = Me.dtExclusions.Rows(i).Item(0) Then
Me.dtPackBom2.Rows(BomRow).Delete()
Me.dtPackBom2.AcceptChanges()
Exit For
End If
Next 'i
Next 'BomRow
WHY IS THIS HAPPENING. SURELY THE EXPRESSION Me.dtPackBom2.Rows.Count - 1 IS EVALUATED EACH TIME THE LOOP IS EXECUTED?
IS THERE A BETTER WAY TO DO THIS?
|
|
|
|
|
Try:
For BomRow As Integer = Me.dtPackBom2.Rows.Count-1 to 0 Step -1
This will count backwards through your rows.
|
|
|
|
|
RichardBerry wrote: SURELY THE EXPRESSION Me.dtPackBom2.Rows.Count - 1 IS EVALUATED EACH TIME THE LOOP IS EXECUTED?
Don't count on it. If you're removing items from a list, it's better to start at the end and work your way back to 0. The way you're doing it now, you'll skip items in the list when you remove one. Say you have 5 items in your list, indexed 0 to 4, and you're going to end up removing item 2:
Index Items
----- -----
0 "This"
1 "is"
2 "was"
3 "a"
4 "test"
Your counter, BomRow, has the value of 2 when you make a check and decide that you want to remove the item at that index. Now, after you remove the item, the Items.Count now says 4. Great! Who cares... You're array now looks like this after you remove the item, but BEFORE you get to the Next statement.
Index Items
----- -----
0 "This"
1 "is"
2 "a"
3 "test"
You finally reach the Next statement and increment BomRow. It's now 3, BUT since the items have moved down the list, you're not checking the item that just got moved to position 2 in the index! You've just skipped an item!
It's better to start at the end of the array and work your way back to 0. That way, you won't be skipping any items, no matter how many items you had to start with and how many you remove in each iteration of the loop.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Thank you Dave!!!!!!!!
That explains a lot of my problems when I see it that way.
|
|
|
|
|
i am trying to read a number from an access table check it and use it to control access to another page.
this is the code snippet where i think the problem is and the feedback i'm getting is saying this "Data type mismatch in criteria expression" - referring to the highlighted line of code below.
Dim PinNumber As String
PinNumber = "SELECT DISTINCT Pin FROM Accounts WHERE Pin='" & Me.tbPin.Text & "'AND AccountID = '" & Me.tbID.Text & "'"
comm.CommandText = PinNumber 'the variable is declared as a command
dr = comm.ExecuteReader 'gives the variable a value
If dr.Read() Then 'if the entry is correct (readable)
Form2.Show() 'show the index varibale (form)
Me.Close() 'close the current form
Else 'if the entry is incorrect
MessageBox.Show("Invalid Pin, please try again") 'displays error message
tbPin.Clear() 'clears the managerid
tbID.Clear()
End If
|
|
|
|
|
You appear to be doing no validation before injecting the values from the user interface into the SQL. An invalid input could be causing problems. It could also be used by a malicious person in order to damage the database.
See SQL Injection Attacks and Tips on How To Prevent Them[^]
|
|
|
|
|
peteyshrew wrote: & Me.tbPin.Text & "'AND AccountID = '"
Don't you need a space before the AND. I.e. "' AND AccountID...
|
|
|
|
|
What he needs is to parameterise the query.
|
|
|
|
|
RichardBerry wrote: Don't you need a space before the AND. I.e. "' AND AccountID...
No... the ' (single quote) acts as a delimiter too, and this will work, provided that PIN is a text type field.
|
|
|
|
|
ChandraRam wrote: and this will work, provided that PIN is a text type field.
And so long as the user doesn't type anything dodgy in to the PIN TextBox because as soon as that happens all hell breaks loose and the company finds that their database is compromised.
|
|
|
|
|
Hi, Im using crystal reports integrated with visual studio.net 2005. Currently, i have a 3 page report, it shows perfectly in the crystal report viewer, but it has problems when i export it.
When i export to word format, only the first page is exported along with a blank page and when i export to PDF format, total 6 pages are exported 3 being the report pages and 3 being blank pages after each report page. I require to export to word format but i have no idea wats causing this problem....any help will b greatly appreciated...its urgent!
|
|
|
|
|
hi...
how to retrive data from buffer
once the data is placed displayed on form
the data has to be deleted from the buffer
that means
once the data is displayed from the buffer ..the buffer should clear the displayed data and the next data has to be stored in that.....
this process must continue like that.....
thanks & Regards
|
|
|
|
|
What interface are you using to read the buffer? Are you using the SerialPort class in the .NET framework or are you using P/Invokes to the Windows API?
If you're using the SerialPort class, the buffer is automatically cleared once you call any of the Read() methods - there are several of them for reading to the end of the available data, reading a line, reading a character, reading a byte, etc.
------------
Cheers,
Patrick
|
|
|
|
|
Help me now!
I want to know the face detection algorithm and face recognization. Nobody known to help me.
Thank so much.
My email: leminhtuan75@yahoo.com
Học, học nữa, học mãi.
V.I.Lê Nin.
|
|
|
|
|
Please do not spam the entire site. Type your question in to google instead.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"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 )
|
|
|
|