|
well you're right about it being easy
if you also happen to have the latest MSDN (free for the express editions)
you'll find great little tutorials there
anyways all you have to do, is follow the wizard in adding a new data source.
there you'll find options as to what kind of database you'll link to.
(choose from SQL Server, or MS Access database)
After that, it'll import the tables and views from the database.
Also it will ask you if you want to make a copy in your working directory or link it permanently
to the database.
(I suggest the first option which makes a new copy after each compile. Otherwise it;s not easy to distribute an application with it's database hardcoded into the application)
Now the easiest way, is to open your form in design view, and go to your data sources, and simply drag and drop the table you want.
have a look at the options then, and you'll quicly get the hang of it.
hope i could help ![Big Grin | :-D](https://www.codeproject.com/script/Forums/Images/smiley_biggrin.gif)
|
|
|
|
|
Hi,
Thanks for your reply. However were do I find the 'Adding a new data source' wizard?
Thanks in advance.
Jaidev
|
|
|
|
|
Once you've opened a project in VB.NET (i'm using VB.NET Express 2005)
To the right you will see the "Solution Explorer" Panel
Underneath that, you'll see 2 tabs by default. Solution Explorer and Data sources.
Hit data sources, and if you haven't added any, it should have a link to the wizard to add a new one.
Also in the data sources panel you'll find anything you need to handle your data sources.
Hope i could help
|
|
|
|
|
Hi,
Im using microsoft visualstudio 2003.net, I haven't the options you've listed however I have found a way to add the DB to my program, but I cannot click and drag the fields I need to put into the program, how do I go about putting the fields I require.
I haven't come across a wizard, what I did was click on add exisitng item and then browsed for the DB.
J
|
|
|
|
|
That's right, all the new features I was talking about are new to 2005.
Well i'm sorry to say that I don't know of any simple ways to add a database, other than the same ways used in VB/VBA, where you manually declare a database type and connect to it using a connection string.
here's a good example where you also see how to pull data, like an image and put in on a picturebox.
http://support.microsoft.com/kb/321900/en-us?spid=2965&sid=global
It's much easier in 2005 if you are concidering updating. (Also the 2005 Express editions are free)
|
|
|
|
|
Hello,
In an app I am writing, I have a couple of subs that first make some changes to my form controls, then fire one of two data access routines.
The problem is that before the controls completely change, the data access routine fires and the app doesn't respond while it waits on the data access routine to complete. It's not causing any problems, other than it's not aesthetically pretty.
I thought I would put a wait timer between the control changes and the data access routine, maybe 500 milliseconds.
I can't figure out how to make it work, and none of the samples I've found deal with anything as simple as what I want to do.
Private Sub btnShipConfirms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShipConfirms.Click<br />
GroupBox1.Text = "Shipping Confirmation Data"<br />
btnShipConfirms.Enabled = False<br />
btnOrderConfirms.Enabled = True<br />
btnSendAll.Visible = False<br />
btnSendAllShip.Visible = True<br />
<br />
'this is where I thought it would make sense to put a timer<br />
Timer1.Interval = 5000<br />
Timer1.Start()<br />
MessageBox.Show("here")<br />
<br />
'run data access routines<br />
CreateShipConfirmTempTable()<br />
RefreshShipConfirm()<br />
Thanks for any help.
Mike
|
|
|
|
|
That's not what a Timer is for. A Timer fires off an event every interval milliseconds so you can do something repeatedly.
If you want the controls to change before your data-intensive code starts, just put in a Application.DoEvents() so the controls have a chance to get and process their paint events.
Private Sub btnShipConfirms_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShipConfirms.Click
GroupBox1.Text = "Shipping Confirmation Data"
btnShipConfirms.Enabled = False
btnOrderConfirms.Enabled = True
btnSendAll.Visible = False
btnSendAllShip.Visible = True
Application.DoEvents()
'run data access routines
CreateShipConfirmTempTable()
RefreshShipConfirm()
.
.
.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
how i can use the usb port in vb.net?
|
|
|
|
|
You can keep posting the same question over and over, but the answer doesn't change!
You can NOT read/write the USB ports in any way similar to the serial port or parallel port. You MUST write your code to communicate with the device you want in the manner that the device expects. How you do that is ENTIRELY dependant on the DEVICE you want to talk to, NOT the USB port.
What exactly are you trying to do, and don't say "use the USB port". That doesn't make any sense.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
On your code-behind (aspx.vb) page add the following:
Private Function ValidateFormControls() As Boolean
Dim ReturnValue As Boolean = True
If txtFirstName.Text.ToString.Trim = "" AndAlso txtLastName.Text.ToString.Trim = "" Then
ReturnValue = False
End If
ValidateFormControls = ReturnValue
End Function
Code snippet:
Try
If Page.IsValid = False Then Exit Sub
If ValidateFormControls() Then
ReturnValue = objBCBusiness.SaveBusinessName(objAddName)
If ReturnValue = "" Then
ShowBusinessInfo()
End If
ClearTextBoxes()
Else
lblMessage.Text = "All fields cannot be empty."
End If
Note: Add the following to your aspx page:
asp:Label ID="lblMessage" CssClass="red_text" runat="server"
Use the Boolean data type to contain two-state values such as true/false, yes/no, or on/off. The default value of Boolean is False.)
|
|
|
|
|
So is there a question in here? Or are you just posting a public service announcement? And a bad one at that...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well if the question is - "How do I validate a textbox client side?" then use JavaScript
Steve Jowett
|
|
|
|
|
Hi,
I am facing one huddles in my project.If any one gives solution then it would be great.
let me describe :
We have user requirement that user has to upload .csv file from client browser which contains around 4 columns.Columns includes like firstname,lastname,SSN,DOB field.Now when user upload .csv file (which may containts more then 10K records) we have to validate those fileds format like firstname should be charater no numeric values include,each SSN value should be numeric not character values like that,so now how can i validate each and every value of each column for 10k records???
we are using asp.net with vb.net(as code behind).Can any body suggest me the good solution for that.??If you have any doubt to understand then feel free to ask me.
I will thankfull for that in advance.
regards,
montu3377
|
|
|
|
|
montu3377 wrote: how can i validate each and every value of each column for 10k records???
In a loop? I really don't understand what you are having difficulty with.
I think the problem is insufficiently defined.
For example:
What are you using to parse the file?
What is to happen if an error occurs? Do you stop the process or do you skip the line?
If you continue, how do you want to report it? Should it log if for an admin to look at, or should the user doing the upload be told?
|
|
|
|
|
Hi ,
ok Good questions:
let me give all answers :
let's say .csv file has 10K rows with column firstname,lastname,SSN,DOB.Now you are checking record by record and if you find firstname in bad format like numeric then count that row as bad row and then continue for next record and like that you can get how much are good records and how much are bad records and at end of the finding,you need to show to user that let's say 1000 records are bad and 9000 records are good out of 10,000 records.
This is how you have to report to user,so user can understand that what's problem with rest of records which are bad.
so user can change those records and then upload .csv file again.
I hope your now clear abt output.My main problem is to how to validate each and every rows (records).??If i will count one by one record then performance will be def. a issue.
regards,
Montu3377
|
|
|
|
|
montu3377 wrote: My main problem is to how to validate each and every rows (records).??If i will count one by one record then performance will be def. a issue.
You don't have a choice here. You have to go through this file, one record at a time, parse and validate each field. A RegEx expression would probably speed things up a little bit.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: RegEx expression would probably speed things up a little bit.
And since you are going to use the same 4 or 5 RegEx you may want to consired precompile them.
montu3377 wrote: If i will count one by one record then performance will be def. a issue.
If the Business does not require a sync response, then fire a new thread to do the validation and then email a report when complete.
Just some other options.
You can only be young once. But you can always be immature.
- Dave Barry
|
|
|
|
|
I have a sub procedure that cleans a text file and write it to the console. Now I need some help appending that cleaned text file to its specified path. Here is the code that I have:
Private Sub CleanFile()
'Read file line by line
Dim file_name As String = "c:\Scanning files\lsprint_MO.txt"
Dim textline As String
If System.IO.File.Exists(file_name) = True Then
Dim objReader As New System.IO.StreamReader(file_name)
Do While objReader.Peek() - 1
textline = objReader.ReadLine() & vbNewLine
If textline.IndexOf("xxxxxxx") = 17 Then
Console.WriteLine(textline)
WriteFile(textline)
End If
Loop
End If
End Sub
Private Sub WriteFile(ByVal fname As String)
Dim oWrite As System.IO.StreamWriter
oWrite = IO.File.AppendText("c:\Scanning files\lsprint_MO.txt")
End Sub
When I run the program I get the following message:
The process cannot access the file 'c:\Scanning files\lsprint_MO.txt' because it is being used by another process.
Any ideas!
jds1207
|
|
|
|
|
Hi,
You are seeing this problem because the WriteFile() function is trying to open a stream to the same file opened in the CleanFile() function.
A quick and easy solution is to create a temporary output file and pass its filename into the WriteFile() function, then at the end of the CleanFile() function delete the original c:\Scanning files\lsprint_MO.txt file and then rename the temporary file...
You can get a temporary file name by:
dim Temp_file as String = my.Computer.FileSystem.GetTempFileName()
Then update WriteFile() function:
Private Sub WriteFile(ByVal OUTPUT_FILE as String, ByVal fname As String)
Dim oWrite As New System.IO.StreamWriter(OUTPUT_FILE)
oWrite = IO.File.AppendText(fname)
End Sub
At the end of CleanFile()
ObjReader.Close()
My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt")
My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt")
I hope this helps you out....
Regards
Martin
|
|
|
|
|
I got this error message: Illegal characters in path.
This line was highlighted:
Dim oWrite As New System.IO.StreamWriter(Output_File)
Also, am I on the right track?
Private Sub CleanFile()
'Read file line by line
Dim file_name As String = "c:\Scanning files\lsprint_MO.txt"
Dim textline As String
Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName
If System.IO.File.Exists(file_name) = True Then
Dim objReader As New System.IO.StreamReader(file_name)
Do While objReader.Peek() - 1
textline = objReader.ReadLine() & vbNewLine
If textline.IndexOf("xxxxxxx") = 17 Then
'Console.WriteLine(textline)
WriteFile(textline, "c:\Scanning files\lsprint_MO.txt")
End If
Loop
objReader.Close()
My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt")
My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt")
End If
End Sub
Private Function WriteFile(ByVal Output_File As String, ByVal fname As String) As Boolean
Dim oWrite As New System.IO.StreamWriter(Output_File)
oWrite = IO.File.AppendText(fname)
Thanks!
jds1207
|
|
|
|
|
I notice you have got the parameters the wrong way round in your call to the WriteFile() function.... You are basically on the right track:
Here is my (slightly corrected) version of your WriteFile() function:
Private Sub WriteFile(ByVal Output_file as string, ByVal The_text as String)<br />
Dim oWrite As System.IO.StreamWriter<br />
<br />
If File.Exists(Output_file) = False Then<br />
' Create a new file to write to.<br />
oWrite = IO.File.CreateText(Output_file)<br />
Else<br />
' Append to file<br />
oWrite = IO.File.AppendText(Output_file)<br />
End If<br />
<br />
oWrite.WriteLine(The_text)<br />
oWrite.Flush()<br />
oWrite.Close()<br />
End Sub
And here is my version of your CleanFile() Function:
Private Sub CleanFile()<br />
'Read file line by line<br />
Dim file_name As String = "c:\Scanning files\lsprint_MO.txt"<br />
Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName<br />
Dim textline As String<br />
<br />
If System.IO.File.Exists(file_name) = True Then<br />
Dim objReader As New System.IO.StreamReader(file_name)<br />
<br />
Do While objReader.Peek() - 1<br />
textline = objReader.ReadLine() & vbNewLine<br />
<br />
If textline.IndexOf("xxxxxxx") = 17 Then<br />
'Console.WriteLine(textline)<br />
WriteFile(Temp_file, textline)<br />
End If<br />
Loop<br />
objReader.Close()<br />
My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt")<br />
My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt")<br />
End If<br />
End Sub
One thing to note here, your original lsprint_MO.txt file will be overwritten by the process of running CleanFile()....
I hope this clears everything up for you....
Have fun and best regards,
Martin
|
|
|
|
|
I have the program running but it has been running for quiet a while now. Does it suppose to take this long to complete?
jds1207
|
|
|
|
|
I guess it will all depend on the size of the input file....
Perhaps a tweak to the "while" loop inside your cleanFile() function may help speed things up:
Private Sub CleanFile()<br />
'Read file line by line<br />
Dim file_name As String = "c:\Scanning files\lsprint_MO.txt"<br />
Dim Temp_file As String = My.Computer.FileSystem.GetTempFileName<br />
Dim textline As String<br />
<br />
If System.IO.File.Exists(file_name) = True Then<br />
Dim objReader As New System.IO.StreamReader(file_name)<br />
<br />
Do<br />
textline = String.Concat(objReader.ReadLine(), ControlChars.NewLine)<br />
<br />
If textline.IndexOf("xxxxxxx") = 17 Then WriteFile(Temp_file, textline)<br />
<br />
Loop Until textline Is Nothing<br />
<br />
objReader.Close()<br />
My.Computer.FileSystem.DeleteFile("c:\Scanning files\lsprint_MO.txt")<br />
My.Computer.FileSystem.RenameFile(Temp_file, "c:\Scanning files\lsprint_MO.txt")<br />
End If<br />
End Sub
Other than that, I'm affraid I have no ideas.....
Regards,
Martin
|
|
|
|
|
Hi all,
I am writing a VB.Net application that has a Command Prompt, which is running as a hidden process and I am redirecting the standard input/output from this process to my own user interface.
Everything seems to be working fine for regular DOS commands, for example; If I type "DIR" into my user-interface it displays exactly the same as if I'd typed DIR in to a command prompt window -- no problems there....
If I enter the name of an executable that is a windows based application, for example notepad.exe, then nothing seems to happen. If I then close my application the program I tried to start (i.e. Notepad) magically appears.
Having delved a bit deeper into this, I notice that after executing the notepad.exe command in my user interface, task manager is showing a "notepad.exe" process running but its not visible. I tried executing the dos command "start notepad.exe", and hey presto - the Notepad application starts up and is immediately visible.
Does anybody have any ideas as to why my hidden command prompt process is not making windows based applications immediately visible (unless they are proceeded by the "start" command)??
Thanks,
Martin
|
|
|
|
|
I can duplicate your problem, but I can't figure out why it's doing what it is. I think it has something to do with UseShellExecute , but you don't have much of a choice there considering you can't redirect the Streams without it being False .
The reason I say this is because you start the CMD process WITHOUT the shell. Any process that's launched from that CMD will ALSO not be launched from the Shell. The START executable gets around that by creating a new instance of the Shell and launching your command line through that (I THINK!). Funny thing is that you can't launch your hidden, or otherwise, CMD process with "START CMD.EXE" while UseShellExecute is False ! You also can't tell your successfully launched hidden CMD process to launch another CMD process using START ("CMD.EXE /K START CMD.EXE") without a Win32 error stopping you.
Sorry, it looks like there is no way around this that I can think of...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|