|
I wanted to close the loop on this and document my decided solution for the benefit of the next newbie that asks this question on validation.
I dragged a errorprovider component from the Toolbox onto my form. Then I place the following code afte the "leave" event for each field:
'begin data type error trapping here
erpTimeSheet.SetError(txtMonday1, "")
erpTimeSheet.SetError(txtTuesday1, "")
erpTimeSheet.SetError(txtWednesday1, "")
erpTimeSheet.SetError(txtThursday1, "")
erpTimeSheet.SetError(txtFriday1, "")
erpTimeSheet.SetError(txtSaturday1, "")
erpTimeSheet.SetError(txtSunday1, "")
If Not IsNumeric(txtMonday1.Text) Then
erpTimeSheet.SetError((txtMonday1), "Your hours must be a number")
txtMonday1.Focus()
txtMonday1.SelectAll()
txtMonday1.ForeColor = Color.Red
Exit Sub
End If
This works. Thanks
|
|
|
|
|
hi
I'm trying to write a code that create DB & tables in MS access using VB, when I excute my code the DB is created but I don't see any table in the DB when I open the access file.
Can any one tell me what's the problem?
This is my code:
Public Function CreateAccessDatabase(ByVal DatabaseFullPath As String) As Boolean
Dim bAns As Boolean
Dim cat As New ADOX.Catalog()
Dim table1 As New ADOX.Table()
Dim cn As ADODB.Connection
cn = New ADODB.Connection
Try
Dim sCreateString As String
sCreateString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseFullPath
cat.Create(sCreateString)
bAns = True
Catch Excep As System.Runtime.InteropServices.COMException
bAns = False
'Open the connection
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\testdb.mdb")
'Open the Catalog
cat.ActiveConnection = cn
'Create the table
table1.Name = "Test_Table"
'Create and Append a new field to the "Test_Table"
'Columns Collection
table1.Columns.Append("PrimaryKey_Field", ADOX.DataTypeEnum.adInteger)
'Create and Append a new key. Note that we are merely passing
'the "PimaryKey_Field" column as the source of the primary key.
'Thi snew Key will be Appended to the Keys Collection of
'"Test_Table"
table1.Keys.Append("PrimaryKey", ADOX.KeyTypeEnum.adKeyPrimary, "PrimaryKey_Field")
'Append the newly created table to the Tables Collection
cat.Tables.Append(table1)
' clean up objects
table1 = Nothing
cat = Nothing
cn.Close()
cn = Nothing
Finally
End Try
Return bAns
End Function
|
|
|
|
|
Fromi what I've seen, this should work. The only problem I can see is that you are specifying the connection string twice, built by two seperate methods.
This is one method:
mesho wrote: Dim sCreateString As String
sCreateString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DatabaseFullPath
cat.Create(sCreateString)
which takes a database file path as a parameter.
The other speicifies a very specific filepath, which could be very different from the above path:
mesho wrote: 'Open the connection
cn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\testdb.mdb")
'Open the Catalog
cat.ActiveConnection = cn
This is probably where you're probliem lies. You're looking in one file for the table, but the table was created in another file.
|
|
|
|
|
Hi There
I have an ownerdrawn listview that is drawing the text in listview1_drawsubitems just fine. My problem is I want to draw an icon in the listview1_drawitem (the first column.)
I am using the code below to add text to the listview (along with icons from an imagelist
If x=2<br />
Dim myItems As New ListViewItem("", 0)'0 is the first omage in the imagelist<br />
listview1.Items.Add(myItems)<br />
myItems.SubItems.Add(firstname)<br />
myItems.SubItems.Add(lastname)<br />
End If
And I want to use this code to draw the different icons in the different rows of the first column:
Public Sub myDrawIcon(ByVal e As PaintEventArgs)<br />
<br />
Dim newIcon As New Icon("sample.ico")<br />
Dim rect As New Rectangle(0, 0, 16, 16)<br />
e.Graphics.DrawIcon(newIcon, rect)<br />
End Sub
And I do not know how. I do not know what to pass as an agrument to the mydrawincon sub to draw icons instead of text in the first column.
The icons do not have to come from the imagelist I can do away with the imagelist and get the icons from my resources if need be.
Any help....Please
Thanks
|
|
|
|
|
Hi,
In regards to your query I would suggest you to try the following code snippet to add icons in the ListView from an ImageList.
--------------------------------------------------------------
BEGIN CODE
Images can be set programmatically when items are adding by setting the image index property of the new item:
Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) _
Handles MyBase.Load
' Add a new item to the ListView
Dim item As ListViewItem = ListView1.Items.Add("Item6")
' Set the index into the image list
item.ImageIndex = 6
End Sub
END CODE
--------------------------------------------------------------
I hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hello! In my project ,i'm using user controls to validate input to my database but any time i'm trying to build a setup project i have this error unable to update project dependencies.It it dues to my user control dll?Ive seen that many people have the same bug.I just need some guidance to build my setup.
PS:i did all the refencing stuff.Thanks
eager to learn
|
|
|
|
|
highjo wrote: i did all the refencing stuff
When you added references to these user controls, did you add the reference to the generated .DLL, or to the project that these controls were in?? I hope it was the project...
|
|
|
|
|
well!
actually i have oe projet A that uses user controls of the Project B.SO in the project A i added the reference to the project B.Then add deployment project to the Project A.Did something wrong?
eager to learn
|
|
|
|
|
The background is that my program adds data to a MS-Access data-bound table programatically.
Here is how I am testing:
1) I test the error handling by adding a record that I know will violate the primary key and I receive the OleDb.OleDbException exception. (OK, I can deal with that ...)
2) I then perform a successful addition of a record. (Still OK ...)
3) I then re-test the error handling by adding a record that I know will violate the primary key and now I recieve the ConstraintException exception. (Huh ???)
4) Now after I continue to test the program I will receive the ConstraintException exception.
It also appears that if I don't do some sort of cleanup then when I try to add a row that I know is good, it continues to fail because it is trying to add the record that previously failed. To get around this I added RejectChanges and RemoveCurrent logic and now my applications seems to operate correctly under all testing conditions. I just don't feel confident that this is the correct way to handle the situation.
Why am I getting 2 different execptions for the exact same code execution ?
Also, please tell me the best way to handle the situation of key/constraint violation.
Why should I have to Reject changes or remove the row from the BindingSource ?
Thanks,
David
Rough code sample follows:
<br />
Try<br />
<br />
schedDR = CType(CType(Me.PP_ScheduleBindingSource.AddNew, DataRowView).Row, TCDataSet._PP_ScheduleRow)<br />
<br />
schedDR.SchedDate = dTmp<br />
schedDR.SiteID = sSite<br />
schedDR.EmpID = sEmpID<br />
schedDR.TimeOpen = sOpenTime<br />
schedDR.TimeClose = sCloseTime<br />
<br />
Me.PP_ScheduleBindingSource.EndEdit()<br />
Me.PP_ScheduleTableAdapter.Update(Me.TCDataSet._PP_Schedule)<br />
<br />
Catch ex As OleDb.OleDbException<br />
schedDR.RejectChanges()<br />
MsgBox("caught dbException" + vbCrLf + ex.Message)<br />
<br />
Catch ex As ConstraintException<br />
Me.PP_ScheduleBindingSource.RemoveCurrent()<br />
MsgBox("Caught Constraint Exception" + vbCrLf + ex.Message)
|
|
|
|
|
Do the exceptions occur on the exact same line?? Usually, it's the exact nature of the data that causes differing exceptions. Sometimes a piece of data will violate the dataset's constraints, and sometimes it'll pass that, but bomb when written to the database. You'll get a different exception for each case. The dataset in code can't replicate the exact constraints comming out of the database.
|
|
|
|
|
I think I found the cause of the confusion on my part. It appears that previously my application was not calling the Me.PP_ScheduleTableAdapter.Fill(Me.TCDataSet._PP_Schedule) prior to attempting to update the table adapter.
My code now calls the Me.PP_ScheduleTableAdapter.Fill(Me.TCDataSet._PP_Schedule) during form_load and I can now consistently trap for the error; ConstraintException. Life is good.
Thank you for your help.
|
|
|
|
|
I have a UDT I created in SQL Server Express 2005 that is called time. I did not create an assembly so the date is always 1/1/1900.
I need to know how to get the time only from the data row.
How do I do that?
Here is a line of code in VB.NET. ts_from is the field in the database that hold the datetime value.
startTime = Convert.ToDateTime(row("ts_from"))
|
|
|
|
|
Why have you created a UDT? You can just use the datetime data type.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hello
Thought I turn off option Type inference , I still has problem
Shared Sub Abc(Of T)(ByVal def As T)
End Sub
Shared Sub Abc(ByVal def As Object)
End Sub
Shared Sub New()
Abc("a string") '---> this line always calls Abc(Of String)(ByVal def As String)
'I really don't want to change existing code to Abc(CObj(""))
End Sub
|
|
|
|
|
You don't have a choice. Think of it this way... The compiler is going to automatically generate code specific to each type that uses this method. If you leave this setup the way it is, the method defined as ByVal def As Object will only be called when you pass something boxed in an Object type. Every other type will go to the generic version of the method.
|
|
|
|
|
I'm working on small desktop application and I need to create a Help file. Like every application made on Windows, that opens help/help file on F1 hit. But unfortunately I have never done this before!! Can anyone tell me how can I create (.chm) Help Module/file?
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
Download HTML Help Workshop
"I love deadlines. I like the whooshing sound they make as they fly by." (DNA)
|
|
|
|
|
Thanks! Just downloaded it. A bit confusing but will get used to it. Thanks again.
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
After then read this article i think since you have not done this before would be helpful
eager to learn
|
|
|
|
|
Thanks
- Stop thinking in terms of limitations and start thinking in terms of possibilities -
|
|
|
|
|
hello.
it is necessary to create DSN for using crystal report.
without using DSN we can create a crystal report.
i want to generate a dynamic crystal report from visual basic 6.0 and backend used is oracle.
i tried it but giving error like 'server not yet been started'.
i don't know TNSname for oracle.
give me reply.
if possible then a code for generating dyanamic report. with backend oracle.
|
|
|
|
|
Hi all
i have created a new projected in vs2005.
added the cystal report designer to the form.
when i insert a new report, i get the following error....
"Crytal Reports Active X Designer" - msg header
"Failed to open document" - error msg.
2nd error box says
"Microsoft Visual Studio" - header
"Failed to create crystal query engine" - error msg.
i have created reports successfully before and dont know why i am getting this error.
i have unintalled crystal and re-installed, still did not work...even tried this = "C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\CrystalReports\CRRedist2005_x86.msi"
no luck...
could you help..please as i need to get my projects out!!!!!
thanks
|
|
|
|
|
1 . tell me which Crystal Report Version you have to impliment with your project ?
2. Embeded Crystal Report or external ?
mitesh
|
|
|
|
|
hi, thanks for the reply....
problem has been sorted out,
was using vs2005..
|
|
|
|
|
Can you post your solution here, I am having the same issue.
Thank You
|
|
|
|