|
I am extracting data from SQL Server to .csv file using VB .net. Some data in the database are separated by enter eg. They used an application to enter the data so when they entered in a list box the pressed enter to go in to a new line.
So, when I extract the data to .csv file, the data after enter they appear in a new cell and not in the same cell as the rest.
How can I remove the ENTER space using vb .net?
|
|
|
|
|
Either the code that produces the CSV file is incorrect, or the code using the file is. If the file is created and read correctly, a newline is perfectly valid inside the data of a field.
A field value should be quoted when it contains a newline. Example CSV data:
Id; Info; Time
1; Hello there; 2006-09-26 18:36:20
2; "This
is
a
perfectly
valid
CSV
file"; 2006-09-28 09:51:12
Note that the values in a 'comma separated value' file often is not separated by commas at all...
---
b { font-weight: normal; }
|
|
|
|
|
Look into the String.Trim[^] method to remove any whitespace characters from the beginning and end of a string before you write the data out to the CSV file.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
How do i change the size of all the controls in the VB.Net 7.0 application
I need your help.
|
|
|
|
|
Do you mean at design time or run time ? I'll assume run time. If you set the anchor property on your controls, they will resize with your form. Otherwise, you can set the X, Y, Width and Height properties on the controls manually, if you need to ( you usually don't ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
How to add buttons in GIF format from net to application
I need your help.
|
|
|
|
|
Do you mean animated GIFs ? To do that, you need to download or write code that animates GIFs, there is an article on this site, but in C#, I think.
To load a standard GIF, Bitmap.FromFile will work fine.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
New to programming, about 5 to 6 weeks of class.Question is what is the code for incrementl loops(to auto increment a primary key value)
This is what i want.
|
|
|
|
|
I nearly deleted two of your posts. Try to give your posts subjects that actually mean something, although you should mention the VB version in the text of your post.
You want to write a loop which increments a primary key ? A primary key is a value in a database, I doubt this is what you mean. Do you just mean a simple loop ? You've had 6 weeks of classes, right ? And google works on your machine ? Have you bought any books on VB ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yes i do want a code to help me increment values of a primary key in a database so as not to get an error on duplicte data entry.And yes i do have a well running Google interface.Both simple and complex code will do as i advance.
I need you help.
|
|
|
|
|
OK - when you create your table, use the word IDENTITY on the primary key, and the database will fill that value for you, incrementing it automatically.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
How can i include any program(setup program ex. winamp) in Deployment of program, so both programs will be installed by setup the deployment
|
|
|
|
|
How are you deploying ? I tend to write a little C++ app to run my MSI, install .NET and any other drivers I may need.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If I have understood you problem correctly, you should enter the following SQL command string:
"...WHERE ti.itemcode=" & i.itemcode & " and v.vendorid= " & i.vendorid & " and ..."
|
|
|
|
|
If you read the thread below, he's apparently tried that. I suspect he needs to post his code.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There is no where clause in this code. A few nested selects, however, this query will be slow, I would expect.
This is a SQL statement, the problem appears to be in the code which adds a where clause, and uses your variables to do so. Where is this code ? Does it exist ? Where does this SQL come from, is it a stored proc ? You've not posted any VB code, does this SQL get generated in VB ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK - you told me you were writing code. You're not, you're using some sort of wizard.
We're back to the point where the only advice I can offer is to write your own data layer, in code. Hopefully, someone who uses the stuff you're choosing to use can offer some other advice.
Here's an example that uses a stored proc:
http://www.developersdex.com/gurus/code/479.asp[^]
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Yes, the right way to do data access is stored procs, which take parameters.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
campbells wrote: I have create the global variable for User option which suppose will refer to param1 and param2...
Is this VB6, or by global do you just mean a public variable on a class ? Either way, this is bad design, you should do better.
I would suggest the best thing to do is to write your own SQL code ( which also means you can put it in a data layer where it belongs ), then you won't be fighting a wizard.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
campbells wrote: but~sure i cant put it like that cause the data command SQL will not regonize wat it the cfrom and cto variable
If you're just creating SQL, remember you're creating a static string, it's not going to be parsed. You need to make sure you're passing in the VALUE of your variable, and not it's name
s = s & " where bizdate<=" & cfrom & " and bizdate >= " & cto
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
OK - it's VB6 ? No, I would attack anyone who tried to put that on my machine
Like I said, sounds like your playing with wizard generated stuff, this never happens to me when I deal with databases entirely in code, and the other bonus is, I get to have a proper data layer.
I don't know what the Microsoft data environment is, but it sounds hideous. Hopefully, someone else knows more and can give you more specific help for the approach you're taking.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello all,
Perhaps you can help me. I have a com object which I converted from VB6 to VB.NET. I am using this com object with other .Net applications without any problem. However, I am now trying to use this com object in some old ASP code which I have not yet converted. I want to use the com object because it contains some additional functionallity that the original com object did not possess. The ASP code works fine when calling the old com object. BUT..if I change the code to call the new com object, it takes a very very (60secs.) long time for the object to be instantuated. In other words, when the code hits the CreateObject line, it takes 60 secs to execute. The rest of the calls to the methods of that com object execute normally. What am I doing wrong? I am including code snipplets of both the VB.NET com object and the ASP page.
Thank you in advance.
Michael Gisonda
VB.NET---------------------
Option Strict Off
Option Explicit On
Imports System.EnterpriseServices
Imports System.Reflection
Imports System.Runtime.InteropServices
<assembly: assemblyversion("3.0.0.0")="">
<assembly: comcompatibleversionattribute(1,="" 0,="" 0)="">
<assembly: applicationname("estsyspro_net")="">
<assembly: assemblykeyfileattribute("n:\projects\estimpact.net\bin\estsyspro.snk")="">
<system.runtime.interopservices.progid("estsyspro_net.custinfo")> Public Class Custinfo
Inherits ServicedComponent
Private gImpConn As ADODB.Connection
Private mConnection As Object
<autocomplete()> Public Function GetBlanketContractInfo(ByVal contract As String, ByVal stockcode As String, Optional ByVal companyid As String = "L") As ADODB.Recordset
Dim sSQL As String
Dim rsRetRecord As New ADODB.Recordset
Dim rsGetRec As New ADODB.Recordset
Dim lLocalConnection As New ADODB.Connection
'Take the company id provided by the user and make it capitalized and only the first letter.
companyid = UCase(Trim(Mid(companyid, 1, 1)))
'Set the connection string to the proper company based on the companyid
lLocalConnection.ConnectionString = fnGetConnectionString(companyid)
'Open the connection.
lLocalConnection.Open()
sSQL = "SELECT SorContractPrice.ContractType, SorContractPrice.StockCode, " & "SorContractPrice.Contract, SorContractPrice.StartDate, " & "SorContractPrice.ExpiryDate, SorContractPrice.PriceMethod," & "SorContractPrice.FixedUom, SorContractPrice.FixedPriceCode, " & "SorContractPrice.FixedPrice " & "FROM SorContractPrice " & "WHERE SorContractPrice.Contract= '" & contract & "' " & "AND SorContractPrice.StockCode= '" & stockcode & "'"
rsGetRec = lLocalConnection.Execute(sSQL)
If Not rsGetRec.BOF And Not rsGetRec.EOF Then
rsRetRecord = MakeRS(rsGetRec)
OpenAndFillRS(rsGetRec, rsRetRecord)
Else
rsRetRecord = Nothing
End If
'Clean up
rsGetRec.Close()
rsGetRec = Nothing
lLocalConnection.Close()
lLocalConnection = Nothing
GetBlanketContractInfo = rsRetRecord
End Function
End Class
END VB.NET -----------------------------------------
ASP Code -------------------------------------------
if mcountrycd="001" then
mCountryLbl="L"
else
mCountryLbl="M"
end if
'vvv This line takes 60 secs to execute.
Set IMPC = server.createobject("EstSyspro_NET.CustInfo")
'vvv This line executes normally.
Set IMPCUST = IMPC.GetBlanketCustInfo(Trim(mSysproCustomer),mCountryLbl)
if IMPCUST is nothing then
......
.....
End ASP Code ---------------------------------------
|
|
|
|
|
Really, I don't think you're doing anything wrong, but I'm no expert on ASP. It seems that on that GetObject statement, the NET Framework has to loaded into the ASP process on the server. This can take quite a long time. Depending on the machine config, I've seen .NET 2.0 load times take about 30 seconds, so this could be part of your problem.
After the page successfully loads and gets through this code, try refreshing it or open a new browser window and load the same page. If the second browser window gets through the page quickly (or as expected), this is probably your problem, but unfortunately, I think you're stuck with it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I have tried that, unfortunitely I get the same result.
Mike
|
|
|
|
|
Is there a way I can change only the font size of the contents in a Rich Text box? I've tried using
MainTxt.Font = New Font(MainTxt.Font.Name, 12) but that still removes any bold, italics, etc.
Any thoughts would be greatly appreciated.
Thanks for your time,
Brian
|
|
|
|