|
hello there
i have a file that contain data suchas
ashish sharan dadhich
rupesh kumar swami
asdf zxcv qwer
now i m trying to store every line and every character in the file (text file) in a 2d string array.
and store the data in a excel file like
----------------------------
ashish | sharan | dadhich |
----------------------------
rupesh | kumar | swami |
----------------------------
asdf | zxcv | qwer |
----------------------------
i use the statement
Dim str1 As String() = rtb1.Text.Split(" ")
to store string separated by space, but i don't know how to find the new line char in the line. the previous statement stores the string
str1(0) = ashish
str1(1) = sharan
str1(2) = dadhichrupesh
does some one has as idea to get rid out of that then please tell me .
thnx
hope all of u to understand my problem.
help everyone
|
|
|
|
|
Hi,
I haven't tried this and I am not sure it will work but you could try to split the data in two steps:
<br />
'1. first split the data into lines by line breaks.<br />
Dim lines() As String = rtb1.Text.Split(Chr(13))<br />
Dim words() As String<br />
Dim line As String<br />
<br />
'2. split each line into words and do whatever you want with them.<br />
For Each line In Lines<br />
words = line.split(" ")<br />
'transfer words.GetValue(0) somewhere<br />
'etc<br />
'etc<br />
Next<br />
Hope this works,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hello friends,
i have one query
prepare a vb application with one button install mysql when the user clicks on the install button mys sql setup should run.
How to work on this please can u help me, if u have any sample code please give and help me
Thanks
Praveen Kumar.R
|
|
|
|
|
if you are using vb.net then with your setup project, u can add a custom action install so you need to put the mySql setup in your setup project and do a custom install to make it install..
i have a similar thing done when i had to install codecs automatically for a media player software and it works...
i think an example is when you are installing JDK widout JRE,
0pe it helps you
phatkin
|
|
|
|
|
Hi,
I am trying to Export the ADO Recordset data in Ms Excel.Please help me as soon as possible.
wlink
|
|
|
|
|
|
Thanks Friend,
My problem is solved by your help.It's really pleasure moment for me.Thanks Alot.
Pawan Nepal
from: Nepal(Country)
|
|
|
|
|
TO read a excel file is quite simple using vb. But there is a problem. My excel file is online updatable file.
the excel file become read only when i read the file using vb. So the excel can't update..this is the problem
so plz any body can assist me
thank u
|
|
|
|
|
jamesrajesh wrote: the excel file become read only when i read the file using vb
Is it being opened more than once at a time?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hi
i just want a generic program for reading headers of file (of any type).
Is there any way to do that??
thanx in advance
|
|
|
|
|
|
hi
i just wanna know how to add password checking code to a binary file so that whenever it is executed it should ask the password first????????
I want to achieve that in VB 6.0 and .net
Thanx in advance
|
|
|
|
|
If you're talking about password protecting your own app, then thats easy. Put up a form with a textbox to get the password. Check it against your stored password. If it doesn't match, you can either ask again or quit.
If you're asking how to password protect ANY binary file, forget it. It can't be done in VB6 and isn't practical to do anyway.
|
|
|
|
|
Dear forks,
In my program, an error raise time to time as below,
An unhandled exception of type 'System.ExecutionEngineException' occurred in growthModel.exe
Error raising poit is here, Is this code incorrect? can anybody help me?
always error raising at cmd1.ExecuteNonQuery().
Public Sub delete2()
Dim cmd1 As New System.Data.OleDb.OleDbCommand
Try
cmd1.Connection = cnn1
cmd1.CommandText = "Delete * FROM NutrientComp"
cmd1.ExecuteNonQuery()
Catch ex As ExecutionEngineException
MsgBox(ex)
Finally
End Try
cmd1.Dispose()
Dimuthu
Dimuthu
|
|
|
|
|
dimuthuvbnet wrote: Public Sub delete2()
Dim cmd1 As New System.Data.OleDb.OleDbCommand
Try
cmd1.Connection = cnn1
cmd1.CommandText = "Delete * FROM NutrientComp"
cmd1.ExecuteNonQuery()
Catch ex As ExecutionEngineException
MsgBox(ex)
Finally
End Try
Try like that ~
<br />
Public Sub Delete2()<br />
<br />
Dim cmd1 As New System.Data.OleDb.OleDbCommand<br />
Try<br />
cmd1.Connection = cnn1<br />
cmd1.CommandText = "Delete * FROM NutrientComp"<br />
cmd1.ExecuteNonQuery()<br />
<br />
Catch ex As Exception<br />
MsgBox(ex)<br />
Finally<br />
End Try<br />
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
GOOD Morning Dimuthu
First thing First, Before you place a command text in your command Object
cmd1.CommandText = "Delete * FROM NutrientComp"
you should go to your SQlquery analyzer and check if your SQL statement is correct. i dont remember seing a statement that looks like
Delete * FROM Table
We dont do it like that.
we say
Delete NutrientComp
where Field = this
Or if you want to Delete the whole contents of the Table we use Truncate like this.
Truncate Table NutrientComp
Number 2: while you use ExecuteNonQuery function, you dont include any connection.
see this
Dim SelectText as String = "Select * from myTable"
Dim SqlConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My_Project\test.mdb
Dim myDA As oledb.oledbDataAdapter= New oledb.oledbDataAdapter(SelectText, SqlConn)
Hope it helps
Vuyiswa Maseko
|
|
|
|
|
Hello Agian everyone !
can someone point me the way how to fast searching data in xml with VB.NET/C# ?
i need urgently.
|
|
|
|
|
Anatha wrote:
i need urgently.
Yeah, a lot of that seems to be going around.
How much XML ? Your best bet is the XmlDocument class and XPath, almost certainly
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 )
|
|
|
|
|
Hi, currently I am developing a database application in vb2005 with ms access as a database back end. In my Ms access there is one table name tblProgBudget with the following field:
- ProgID (Number)<br />
- Year (Number)<br />
- ProgBudYear (AutoNumber)<br />
- GovContrib (Currentcy)<br />
- OrgContrib (Current)
I write a code in vb 2005 try to insert new record into this table (I add to all field except ProgBudYear because this field is autonumber field so I want the system to generate it by automatically). The below is my code:
Private Sub btnAddProg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddProg.Click
' Check whether the user select any organization name.
If cboSelOrgName.Text <> "" Then
' Check whether the user select any program/project name.
If cboSelProgName.Text <> "" Then
' Check whether the user enter a correct year format.
If Len(txtYearBudPlan.Text) = 4 Then
' Declare a new command to get program/project id.
Dim cmdGetProgID As New OleDbCommand
With cmdGetProgID
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "SELECT tblProgName.ProgID FROM tblProgName WHERE tblProgName.OrgName LIKE '" & cboSelOrgName.Text & "' AND tblProgName.ProgName LIKE '" & cboSelProgName.Text & "'"
End With
' Open the connection.
Try
cmdGetProgID.Connection.Open()
Catch exFileNotFound As System.Data.OleDb.OleDbException
MessageBox.Show("The system has a problem to connect to your database system." & ControlChars.CrLf & "Please verify that your database is located in the following path: 'C:\DICDonorDb\DICDornorDb.mdb'", "Database file not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
Dim drdGetProgID As OleDbDataReader = cmdGetProgID.ExecuteReader
If Not drdGetProgID Is Nothing Then
drdGetProgID.Read()
' Get program/project id from the system.
strProgID = drdGetProgID(0).ToString
' Close the connection
cmdGetProgID.Connection.Close()
' Add an information on the form to the program/project budget.
' Declare the new command.
Dim cmdAddProgBudInfo As New OleDbCommand
With cmdAddProgBudInfo
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "INSERT INTO tblProgBudget (tblProgBudget.[ProgID], tblProgBudget.[Year], tblProgBudget.[GovContrib], tblProgBudget.[OrgContrib]) VALUES (" & Val(strProgID) & ", " & Val(txtYearBudPlan.Text) & ", " & Val(txtGovCont.Text) & ", " & Val(txtOwnCont.Text) & ")"
End With
' Open the connection.
Try
cmdAddProgBudInfo.Connection.Open()
Catch exFileNotFound As System.Data.OleDb.OleDbException
MessageBox.Show("The system has a problem to connect to your database system." & ControlChars.CrLf & "Please verify that your database is located in the following path: 'C:\DICDonorDb\DICDornorDb.mdb'", "Database file not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
' *********************************************
'
' PROBLEM REMAIN IN HERE
'
' *********************************************
' Add an information to the database.
cmdAddProgBudInfo.ExecuteNonQuery()
' Close the connection.
cmdAddProgBudInfo.Connection.Close()
' Clear an information from the variable.
strProgID = ""
' Inform the user after success add an information into the database system.
MessageBox.Show("The program/project budget for the year " & Trim(txtYearBudPlan.Text) & " and its relevant information are successfully added into the database system." & ControlChars.CrLf & "The system will clear an information on the form in order to prepare to add another year of program/project budget.", "Add Year of Program/Project Budget", MessageBoxButtons.OK, MessageBoxIcon.Information)
' Clear an information on the form.
txtYearBudPlan.Text = ""
txtGovCont.Text = ""
txtOwnCont.Text = ""
ElseIf drdGetProgID Is Nothing Then
MessageBox.Show("The program/project '" & cboSelProgName.Text & "' from '" & cboSelOrgName.Text & "' organization does not exist in the database system." & ControlChars.CrLf & "Please verify your an information of this program/project again.", "Program/Project not exixt in database", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If
Else
MessageBox.Show("The year of budget plan require you to enter four digit format." & ControlChars.CrLf & "Example: This year is " & Format(Year(Now()), "YYYY") & ".", "Invalid Year Digit", MessageBoxButtons.OK, MessageBoxIcon.Stop)
txtYearBudPlan.Focus()
End If
ElseIf cboSelProgName.Text = "" Then
MessageBox.Show("You didn't select any program/project.", "Require Selected Program/Project", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If
ElseIf cboSelOrgName.Text = "" Then
MessageBox.Show("You didn't select any organization name.", "Require Selected Organization", MessageBoxButtons.OK, MessageBoxIcon.Stop)
End If
End Sub
When I try to run, there is an except occure as the below detail technical information:
System.Data.OleDb.OleDbException was unhandled<br />
ErrorCode=-2147217900<br />
Message="The INSERT INTO statement contains the following unknown field name: 'tblProgBudget.ProgID'. Make sure you have typed the name correctly, and try the operation again."<br />
Source="Microsoft JET Database Engine"<br />
StackTrace:<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)<br />
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()<br />
at DIC_Donor_Database.frmProgBudget.btnAddProg_Click(Object sender, EventArgs e) in C:\Documents and Settings\roathkanel\My Documents\Visual Studio 2005\Projects\DIC Donor Database\DIC Donor Database\frmProgBudget.vb:line 182<br />
at System.Windows.Forms.Control.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br />
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
at System.Windows.Forms.Button.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.Run(ApplicationContext context)<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br />
at DIC_Donor_Database.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br />
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
at System.Threading.ThreadHelper.ThreadStart()
I feel that I enter the correct table and field name (because it copie the table name and field name from the database). But I can't run this code successfully.
Please give me some advice!!!
|
|
|
|
|
Try just listing the columns without the table name. Also, your strings don't have quotes around them, this will cause an error.
Finally, your database is totally insecure, you need to read up on SQL injection attacks. And, even though this may be a very small app, I'd still advocate architecting it with a proper data layer.
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 )
|
|
|
|
|
Christian Graus wrote: Try just listing the columns without the table name. Also, your strings don't have quotes around them, this will cause an error.
I try to remove as your suggestion. The below is the statement that I just remove:
Dim cmdAddProgBudInfo As New OleDbCommand
With cmdAddProgBudInfo
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "INSERT INTO tblProgBudget (ProgID, Year, GovContrib, OrgContrib) VALUES (" & Val(strProgID) & ", " & Val(txtYearBudPlan.Text) & ", " & Val(txtGovCont.Text) & ", " & Val(txtOwnCont.Text) & ")"
End With
But it still display an error with the below exception:
System.Data.OleDb.OleDbException was unhandled<br />
ErrorCode=-2147217900<br />
Message="Syntax error in INSERT INTO statement."<br />
Source="Microsoft JET Database Engine"<br />
StackTrace:<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)<br />
at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)<br />
at System.Data.OleDb.OleDbCommand.ExecuteNonQuery()<br />
at DIC_Donor_Database.frmProgBudget.btnAddProg_Click(Object sender, EventArgs e) in C:\Documents and Settings\roathkanel\My Documents\Visual Studio 2005\Projects\DIC Donor Database\DIC Donor Database\frmProgBudget.vb:line 182<br />
at System.Windows.Forms.Control.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnClick(EventArgs e)<br />
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)<br />
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
at System.Windows.Forms.Control.WndProc(Message& m)<br />
at System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
at System.Windows.Forms.Button.WndProc(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
at System.Windows.Forms.Application.Run(ApplicationContext context)<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br />
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br />
at DIC_Donor_Database.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br />
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
at System.Threading.ThreadHelper.ThreadStart()
I think the cause of the problem is the value of the autonumber field. I don't know how to set it.
|
|
|
|
|
Let me help you, you have a small problem.
Tell me is the Field "ProgID" an identity Column in your Table?if so state it and i will help you .
Thanks
Vuyiswa Maseko
|
|
|
|
|
Vuyiswamb wrote: Tell me is the Field "ProgID" an identity Column in your Table?
What do you mean identity column? Let go back to my orignial post. The field ProgID and Year were set as a primary key (mean the data in both column) could not be duplicate.
I try to rename the column to the other name, but the system still have an error with the respective column name as the above error that i post.
Hope to see your reply soon!!!
|
|
|
|
|
I went back to your main post.
1st your table is not structured well.
2nd you have to know the Purpose of a Primary key.
3th you have a Column ProgID and you made a Primary key.and had ProgBudYear and made it an Identity Column(AutoNumber). ProgID is a column that serves no Purpose according to view, because there might be dublicate as you suspected. Now i suggest you make ProgBudYear a Primarykey, and keep it as an autoNumber and remove ProgID if you only Put it in your table for the purpose of Primary key.
Then your table will look like this
if ProgBudYear is an identity table then you will not have trouble with duplicates and will make ProgBudYear a Primary key
- ProgBudYear (AutoNumber)
- Year (Number)
- GovContrib (Currentcy)
- OrgContrib (Current)
and when you insert your query should be something like this
insert into mytable
values(1981,14000,20000)
Exclude Identity column.
Hope this help
Thanks
Vuyiswa Maseko
|
|
|
|
|
So what does the CommandText look like just before you execute it??
Also, get rid of the Val functions. In this case, your converting a string to a value then back to a string.
Actually, rewrite that code to use parameterized queries and you won't have to worry about getting every single quote mark correct. It'll make your code more robust and easier to maintain.
|
|
|
|
|