|
Hello everyone,
i got the following problem in VB.net:
I am writing a program that reads out a sql table and concatenates fields of it and put them back in one field.
example:
line 1 textfield1
line 2 textfield2
should look like
line 1 textfield1 textfield2.
i do this by reading a datatable that is filled with the info i needed and then concatenating the textfields and putting them back into a new datatable with the same structure as the old one.
now the problem:
i got this string in two lines.
30,00 % bei Auftragsbestätigung 30,00 % bei Arbeitsbeginn 40,00 % be
i Abnahme
When i save it in the datatable to put it back on the sql server after concatinationg i get this line.
30 % bei Auftragsbestätigung30 % bei Arbeitsbeginn40% bei Abnahme
but it should look like this
30,00 % bei Auftragsbestätigung 30,00 % bei Arbeitsbeginn 40,00 % bei Abnahme
the field i read from is a nvarchar(70) on the sql server.
My guess it has something to do with the type of the datatable field
because it is a string and not a varchar.
if anyone could help me i would really apreciate it.
If you need code examples or anything else post and i will try to deliver.
thanks in advance
|
|
|
|
|
I suspect its to do with the commas. Try enclosing the whole string in single quotes.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
The problem is i already get errors with blanks/spaces when putting the data in the first datatable. My bad for not seeing it earlier.
|
|
|
|
|
Hi all,
Can I prevent OleDbDataAdapter from closing OleDbDataConnetion after filling DataSet?
Thanks for help
|
|
|
|
|
You should be closing the connection when you're done with it.
But, if the connection is already open before you call the Fill method, the adapter will not close the connection when it's done.
If the connection is not open when Fill is called, Fill will close the connection when it's done with it.
So, the answer to your question is to open the connection yourself before you call Fill.
|
|
|
|
|
Hello
I'm experimenting with the Datagridview-Control (DGV). Working with datatables as datasource works very nice. You can use all the functionality like edit, add or delete rows.
But I don't want to use datatables. So I build a class that contains all the fields I need (thats the datarow). These classes are in a list (for example "List (of T)" or "Collection"). Thats works with a static list.
But: Using datatables will show you the NewRow in the buttom of the DGV (if you want that). Using my oun collection dont do that. Even deleting rows is not possible - just editing rows.
So what interfaces I have to implement or what classes I have to derive to get full functionality like a datatable? I would be very glad if somebody could supply me a hint.
|
|
|
|
|
Look into creating your collection using the generic BindingList(T)[^] class. This will give you New, Insert, and Delete capabilities you're looking for.
|
|
|
|
|
Thanks,
that is excactly what I need.
|
|
|
|
|
Hi guys
this is my scenario
i have a shared folder on the server with an exe file in it.
i have a program on the clients pc. when this app launches i want the app to copy the server file and overwrite the client one everytime.
problem is that sometimes the client pc prompts for a username and password to the server, how do i get around this?
this is what i have done thus far, but wud like to know if there is another better method.
Dim credentials As Net.NetworkCredential
credentials = New Net.NetworkCredential("username", "password")
Dim DestFile As Uri = New Uri("c:\programs\addons.exe")
Dim FileToCopy As String = "\\196.96.9.5\cd\addons.exe"
my.Computer.Network.DownloadFile(fieltocopy,destfile,username,password,True ,1000,True ,FileIO.UICancelOption.ThrowException )
thanks for your help
modified on Thursday, March 19, 2009 10:25 AM
|
|
|
|
|
UploadFile?? Is this code running on the server or running on the client machine???
|
|
|
|
|
Hi,
this code runs on the client.
it should be using my.Computer.Network.DownloadFile(fieltocopy,destfile,username,password,True ,1000,True ,FileIO.UICancelOption.ThrowException )
thanks
|
|
|
|
|
how to
tell flash to read xml when press button in vb.net.
just when press button in vb tell to flash read xml
|
|
|
|
|
I don't think any bridge exists between flash and VB. If it does, the people who wrote the flash control you're using would be the ones documenting it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
but i more clever than who wrote flash
i know how to do this now
ha ha ha ha
|
|
|
|
|
No, you're an idiot. You don't know, or you wouldn't have just asked again. You can embed flash in VB, but you can't communicate between them, unless there's a way documented in the flash API. Other people have told you there is not, and yet you ask again...
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
You can use flash only through the standard flash's component interface- The standard features supported to Load/Run/Pause/Stop & many more. If you want to control something other than that, you can provide user interface(May be a Button) in in flash and host the control in a vb.net form. The the Button & the brain sticks with Flash and gets hosted in the VB form. Helps?
He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus
|
|
|
|
|
Hi ,
im getting the below error when im trying to access a html(in which im using Wscript.shell using VBScript...) placed in my server..Should change any settings in internet options....
ActiveXComponent Can"t create object :WScript.Shell
Please help me out.....
|
|
|
|
|
It would be better to ask your question in the ASP.NET or Web Development forums
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
does anyone know how to pass a value from word document to a text box?
thanks in advance..
yours truly,
hyperalergelo
|
|
|
|
|
You can examine word documents using the Office Tools for .NET to interop with Word.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
yes i know, but i'm having trouble using this..
txtResult.Text = activeDoc.Content.Sentences.Item(1)
and this one
txtResult.Text = activeDoc.Content.characters.Item(1)
got any other idea what to use to get value from word document?
yours truly,
hyperalergelo
|
|
|
|
|
I am getting this error on the above code..
Unable to cast COM object of type 'System.__ComObject' to class type 'System.String'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
yours truly,
hyperalergelo
|
|
|
|
|
problem solved..
I'll post it for future reference..
Imports Word = Microsoft.Office.Interop.Word
Imports Office = Microsoft.Office.Core
Partial Class _Default
Inherits System.Web.UI.Page
Private objMisc As New Miscellaneous
Private WordApp As New Word.ApplicationClass()
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
'objMisc.InsertCV("E:\CVParser\CVParser\Files\" & OFDCV.FileName)
' set the file name from the open file dialog
Dim aDoc As Word.Document
Dim fileName As Object = OFDCV.PostedFile.FileName
Dim [readOnly] As Object = False
Dim isVisible As Object = True
Dim fileToOpen As Object = DirectCast("c:\sample.doc", Object)
' Here is the way to handle parameters you don't care about in .NET
Dim missing As Object = System.Reflection.Missing.Value
' Make word visible, so you can see what's happening
WordApp.Visible = False
' Open the document that was chosen by the dialog
aDoc = WordApp.Documents.Open(fileName, missing, [readOnly], missing, missing, missing, missing, missing, missing, missing, missing, isVisible) ' Activate the document so it shows up in front aDoc.Activate();
txtResult.Text = aDoc.Content.Text
aDoc.Close(missing, missing, missing)
WordApp.Quit(missing, missing, missing)
End Sub
End Class
yours truly,
hyperalergelo
|
|
|
|
|
im running this function to convert a list of code into a certain standard.. the problem is, when i choose the files (where i get the value of coop) and directory (where i compare coop with the list in the directory) this msg come out "index out of range exception". But if i choose local file and directory example file from my desktop and my d:/ there's np error.. but if i choose the file from other map drive the error happen at the Catch part.
Private Sub SEMAK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEMAK.Click
Dim fileName As String = TextBox1.Text.Trim
Dim lineNumber As Integer = 0
Dim sr As StreamReader = New StreamReader(fileName)
Dim conn As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA_Latihan;Persist Security Info=True;")
Dim tarikh As String = ""
Dim runNo As String = ""
Dim coop As String = ""
Dim line As String = ""
Do
line = sr.ReadLine()
If line <> Nothing Then
Try
tarikh = line.Substring(0, 8).Trim()
runNo = line.Substring(9, 5).Trim()
coop = line.Substring(15).Trim()
Catch ex As Exception
Console.Write(ex.ToString())
End Try
Dim strSQL As String = "INSERT INTO portal (tarikh,runNo, coop) VALUES (@tarikh, @runNo, @coop)"
Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn)
conn.Open()
cmd.Parameters.Add(New SqlClient.SqlParameter("@tarikh", SqlDbType.Char, 8))
cmd.Parameters("@tarikh").Value = tarikh
cmd.Parameters.Add(New SqlClient.SqlParameter("@runNo", SqlDbType.Char, 20))
cmd.Parameters("@runNo").Value = runNo
cmd.Parameters.Add(New SqlClient.SqlParameter("@coop", SqlDbType.VarChar, 100))
cmd.Parameters("@coop").Value = coop
cmd.ExecuteNonQuery()
conn.Close()
Dim dirB1 As DirectoryInfo = New DirectoryInfo(TextBox2.Text)
Try
convertCoop(coop)
Dim dA1 As DirectoryInfo
Dim dirB2 As FileSystemInfo() = dirB1.GetDirectories
Dim strSQL2 As String = "SELECT folder, portal FROM kodPortal"
Dim cmd2 As New System.Data.SqlClient.SqlCommand(strSQL2, conn)
For Each dA1 In dirB2
If dA1.Name = portal Then
Dim dA2 As DirectoryInfo
Dim dirB3 As FileSystemInfo() = dA1.GetDirectories
For Each dA2 In dirB3
If dA2.Name = "Fail_Bayaran" Then
Dim dA3 As DirectoryInfo
Dim dirB4 As FileSystemInfo() = dA2.GetDirectories
For Each dA3 In dirB4
If dA3.Name = coop Then
Dim dA4 As FileSystemInfo
Dim dirB5 As FileSystemInfo() = dA3.GetFileSystemInfos
For Each dA4 In dirB5
If dA4.Name <> runNo Then
MsgBox(coop)
End If
Next dA4
End If
Next dA3
End If
Next (dA2)
End If
Next dA1
Catch ex As Exception
End Try
End If
Loop Until line Is Nothing
sr.Close()
End Sub
Private Sub convertCoop(ByVal coop As String)
Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA_Latihan;Persist Security Info=True;")
Dim comm As SqlClient.SqlDataAdapter = Nothing
Dim ds As DataSet = New DataSet()
Try
Dim strSQL2 As String = "SELECT folder, portal FROM kodPortal WHERE folder ='" & coop & "'"
conn1.Open()
comm = New SqlClient.SqlDataAdapter(strSQL2, conn1)
comm.Fill(ds, "kodPortal")
portal = ds.Tables(0).Rows(0).Item("portal")
conn1.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Not conn1 Is Nothing And conn1.State = ConnectionState.Open Then
conn1.Close()
End If
conn1 = Nothing
comm = Nothing
End Try
End Sub
|
|
|
|
|
Have you bothered to walk through the code in te debugger ? I assume this means you're not getting any data back from your database.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|