|
I have never used this component in .net but as far as i can remember from VB6 there are a few other properties which will be responsible for your problems.
somewhere there are properties for the placehoder (what you see before you put in the text which is commonly an underscore. eg for the phone number would be '(____)_______'),wether or not to include the placeholder in the text and wether or not to include the literals (in the case of your phone number mask the ()) in the text.
These can cause problems. Eg if the literal '£' is saved with the currency value the DB will complain because Vb will not convert '£10000' from a string to currency. Also if the placeholder is saved you could end up with a '(01245)49367_' for a phone number. If that is a number field the problems would be the literals '()' and the placeholder '_' (OK bad example but you see where i am going).
You need to be careful with this control. The best thing is to set the mask (format) just as the control gets the focus (otherwise it may not accept a value from the DB if it is not in the corrdct format) then unset it and check the text in the validate event. SQL is not forgiving with junk characters and the masked edit control is probably worse.
The long and short of it is dont think that by using this control you can get away without performing any validation of the data because you wont.
Jon
|
|
|
|
|
I want to start on a program that takes in various measurements of square areas, then should graphically display the optimized way of arranging the objects, so to fit the most objects into a set area.
If anyone has got any ideas on algorithms or related sites I can visit to find out more, pls feel free to comment...
Thanx
|
|
|
|
|
I am working on a application that uses the MyApplication_UnhandledException event to basically tell the user that I screwed up somewhere...see below
Private Sub MyApplication_UnhandledException(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs) Handles Me.UnhandledException
MsgBox(e.Exception.Message.ToString)
e.ExitApplication = False
End Sub
My test app that I was working on has 3 controls on it, A menu bar, textbox, and datagrid. The app will take what I have in the textbox aka SQL Query, then use the dataadapter to fill a dataset then bind it to the datagrid. Here is where it gets weird, or at least I have no idea why this happens... First here is my code...
I have a SQL class, which takes the query, and connection string and returns a datatable
Imports System.Data
Imports System.Data.SqlClient
Public Class SQL
Private pResults As New DataTable
Private pQuery As String
Private pConnStr As String
Public ReadOnly Property Results() As DataTable
Get
Return pResults
End Get
End Property
Public Sub New(ByVal ConnStr As String, ByVal Query As String)
pConnStr = ConnStr
pQuery = Query
End Sub
Public Function ExecuteQuery() As DataTable
Dim DBConn As SqlConnection
Try
DBConn = New SqlConnection(pConnStr)
DBConn.Open()
Dim adp As New SqlDataAdapter(pQuery, DBConn)
adp.Fill(pResults)
Return pResults
Catch ex As Exception
Throw ex
Finally
DBConn.Close()
End Try
End Function
End Class
Also here is my main body of the testForm, the menubar has two items one Parent (File) then a child node of Run with a shortcut key set to Ctrl+R
Private Const CONNECTION_STRING As String = "uid=sa;password=SomePassword;initial catalog=SomeDatabase;data source=wwwsql01,1433;connect timeout=15;persist security info=false;network library=dbmssocn"
Private Sub RunToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RunToolStripMenuItem.Click
RunQuery()
End Sub
Private Sub RunQuery()
Dim qry As New SQL(Me.CONNECTION_STRING, TextBox1.Text)
qry.ExecuteQuery()
DataGridView1.DataSource = qry.Results
End Sub
Very simple... If I run it as is and an exception is thrown when I press Ctrl+R while in the textbox, the unhandled exception handler will take over and show me the exception but then place an "r" into the textbox. If I hit Ctrl+R from the datagrid all is fine. If I use the mouse to click on Run all is fine. So If I place a Try Catch around where I call RunQuery() and do not use the MyApplication_UnhandledException but show a messagebox in the Try Catch instead...The "r" as mentioned above does not show up at all. Would anyone know the reasoning behind this? This app is nothing special just a small test before I develop the larger version. All it does is run a SQL query... Thanks in advance for anyhelp that you may be able to offer.
The network is down...let's go get bagels.
|
|
|
|
|
How can I copy the selection of files from the listbox to a desire destination. Is it possible?
In other words I have the file listing from my desire folder, i can select them, no problems, but how can i move or copy my selection from the listbox to a desire destination.
Can I copy: source from listbox listing (c:\windows\mytext.txt) to like dest:(e:\data\mytext.txt).
I need help.
|
|
|
|
|
You're not very specific about what your having a problem with.
Yes you can copy files and directories. All the ListBox will give you, though, is a list of filenames. It will NOT copy the files for you. For this, you'll have to use the File and Directory classes in the System.IO namespace.
Or are you having a problem with how to let your users specify where to copy the files/directories to?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
Dim filename As String
Dim newfilepath As String = "c:\data\"
If Not Directory.Exists(newfilepath) Then
Directory.CreateDirectory(newfilepath)
End If
For i = 0 To ListBox1.SelectedItems.Count - 1
filename = Path.GetFileName(ListBox1.SelectedItems(i).ToString)
newfilepath = newfilepath & filename
FileCopy(ListBox1.SelectedItems(i).ToString, newfilepath)
Next
End Sub
|
|
|
|
|
The textbox on my form does not update the underlying database table.
I created a form with a textbox, a datagrid, and a save button. Using the wizard I created a connection to an Access database, a dataadapter, and dataset.
Then I set the datagrid up to read data from the table and the button to update those changes. That all works fine.
For the textbox I set the text databinding to a field in the database and it does display the correct information. But, if I change the textbox value and execute the dataadapter update the changes do not take. Also, the HasChanges property is false even though I changed the value. How can I get the new textbox value to write back to the table? Thanks for any help!
|
|
|
|
|
This is the code that I got a couple of days from these forums. I have 24 textboxes that this needs to go to. Is there an easier way to get them all in one function/sub or do I have to have 24 different subs?
Private Sub txtBDrain_KeyPress(KeyAscii As Integer)
KeyAscii = LimitTextInput(KeyAscii)
End Sub
Function LimitTextInput(KeyAscii) As Integer
If ((KeyAscii < Asc("0")) Or KeyAscii > Asc("9")) _
And (KeyAscii <> 8) And (KeyAscii <> 13) And (KeyAscii <> 46) Then
LimitTextInput = 0
Else
LimitTextInput = KeyAscii
End If
End Function
|
|
|
|
|
In VB6, you'll have to have 24 different subs. In VB.NET, you can have one sub that handles the same event for all 24 TextBoxes.
But, in either case, since you're using so many of these numeric-only TextBoxes, you're better option would be to make your own TextBox control, inheriting from the standard TextBox and putting this code in that control. Then you can place 24 of the new textboxes on your form without having to worry about this problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
can someone tell me why this error occurs when clicking on the Add new record button! I have a database which i am accing this mdb from vb.net. I made everything good with data set, data adapter and connection to the db. this error occurs:
cannot create a child list for field fastMax Orders. why is this??
|
|
|
|
|
Sounds like a master-detail relationship?
How is the relationship defined?
Is the spelling correct on all column names? Need more info
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
No i have 1 table only! all the names are in good format and they are linked correctly as i can see. I have the dataset dataadapter and connection good!
|
|
|
|
|
I have one question:
In Help about odbcDataAdapter.Update Method is write text:
Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the DataSet.
And when is calling SELECT statement?
I need sometimes calls on my odbcDA select command, which refresh my DataSet. Update can not I call, in my Table is not change, but in Dataset I take data from RelAted Table.
Julo
Julo Jenis
|
|
|
|
|
Update doesn't call a SELECT statement. It's used for UPDATING. All three SQL statements make changes, or UPDATE, the database.
When do you call the SELECT statement? Here's a hint: How did you fill your dataset in the first place?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You need to do OdbcDataAdapter.Fill(dataset)
This will use the select command to fill the dataset
Thanks,
-Len Miller
"If I had eight hours to chop down a tree, I'd spend six sharpening my axe."
-Abraham Lincoln
|
|
|
|
|
Ok, thats clar, but... I have one DataGrid, 5 Tables and relations between Tables. When am I in 3 table, I do som changes. I 2 Table (2.Table is Parent of 3Table) I have one field, which is SUm of fileds in 3 Table. When I come to 2 Table, I need make "Refresh", t.m. SELECT. But when I use FILL, In DataGrid is 1 Table.
Calculated field I cann not use, there is som problem with "Cannot change read only property for calculated field" )
When you know something about my problem, pease help me.
Thanks, Julo
|
|
|
|
|
Hi Folks,
I am looking for a free CTL or COM Control for XML Editing to use from VB6. Binary is okay - source might be nice.
Thanks
Davy
My Personal Blog - Homepage
|
|
|
|
|
Hello,
this is Manoj,doing a project in a company. In my project, I want to send mail (automatically, without click on send & even not displaying the composer window)through vb.net using my microsoft outlook (or anything else if can be used) which is configured to Microsoft Exchange server named bgeexc05. I am generating password automatically for an employee once he enters his empid,that password need to be sent to his emailid (by accessing emailid from database). Below are the error message which i get by using the respective code:
I have put, "Imports System" & "Imports System.Web.Mail" & below codes Written for Click Button
I have also tried for localhost.
Code1:
Dim from As String = "manoj.jahagirdhar@abc.com"
Dim mailto As String = "manoj.jahagirdhar@abc.com"
Dim subject As String = "PWD"
Dim body As String = "UtilMailMessage001 - success"
SmtpMail.SmtpServer = "bgeexc05"
SmtpMail.Send(from, mailto, subject, body)
Error Message1:
"The transport failed to connect to the server"
Code2:
Dim email As New System.Web.Mail.MailMessage
email.To = "manoj.jahagirdar@abc.com"
email.From = "manoj.jahagirdar@abc.com"
email.Body = "MessageText"
email.Subject = "SubjectText"
email.BodyFormat = Web.Mail.MailFormat.Text
System.Web.Mail.SmtpMail.SmtpServer = "bgeexc05"
System.Web.Mail.SmtpMail.Send(email)
Error Message2:
The server rejected the sender address. The server response was: 454 5.7.3 Client does not have permission to submit mail to this server
Also i get get message saying, "Cannot relay on manoj.jahagirdhar@abc.com" ..........
Kindly Help
|
|
|
|
|
Download 101 VB.NET examples from msdn.microsoft.com. There is an example for sending email. You can see what to do from there.
Sounds like either your code is way off track or there is something wrong with the settings on the machine your code is running on.
|
|
|
|
|
As far as i know the smtp server needs to be the server of your service provider that you are connected with not your exchange server. For example if your internet access was with BT your smpt server would be something like smtp.btinternet.com otherwise you could easily spam from anyones email servers.
JJ
|
|
|
|
|
Can you create a VB6 program that does multi-tasking? I have to create a Printed Circuit Board test program that concurrently tests 2 boards.
Thank you for your help in advance.
|
|
|
|
|
VB6 doesn't support multi-threading. It is possible to do, but you can't debug the code using the VB6 IDE. It'll crash the IDE when the code hits a breakpoint. Last time I searched for articles on VB6 multi-threading, I came up empty.
If you really want to do this, I suggest saving yourself the time and aggrevation and do in VB.NET or C#. At least in the .NET Framework, multi-threading is MUCH eaasier to code, debug, and support.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi ppl,
i have a database with only one table named project_name. what i want is that on the page load event the last record of this database should be displayed in a textbox on my web form. how doi do this. i'm using access as my database. please help me.
thanks and regards
manik
|
|
|
|
|
This can easily be done using an SQL statement, something like:
SELECT LAST(fieldname) AS LastProjectName FROM project_name;
This will return a single table, with one row under the column name "LastProjectName".
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanx dave,
it works.
regards
manik nath
|
|
|
|