|
Your old post is here[^], along with my reply to it.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
opps, thx
mus haf posted help at too many forums, missed out, haha
|
|
|
|
|
You have single quotes inside your double quotes. You should only include these for 'string' values. Numbers should not have single quotes. Additionally, 'Date' fields may need octothorpes (#) instead of single quotes.
Your commands are setup a little inefficiently. You should only keep a connection open for the shortest time possible. Do everything else first, then open the connection just before you execute your command, then close immediately.
Try this:
Private Sub AddSubmitB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddSubmitB.Click
Dim strcon As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Jasmine\db.mdb"
Dim con As OleDb.OleDbConnection
con = New OleDb.OleDbConnection(strcon)
Dim cmd As New OleDb.OleDbCommand
cmd.Connection = con
Dim strsql As String
strsql = "Insert into member (BorrowerId, password, MemberType, Fname, Lname, Gender, Address1, Address2, Address3, ContactNo, HandPhNo, Email, CourseOfStudy, EnrolledDate, ExpiryDate) values ('" & StudIdTB.Text & "','" & StudPwTB.Text & "','" & UgTB.Text & "','" & StudFnTB.Text & "','" & StudLnTB.Text & "','" & StudGenderCLB.Text & "','" & StudAdd1TB.Text & "','" & StudAdd2TB.Text & "','" & StudAdd3TB.Text & "','" & StudHmTB.Text & "','" & StudHpTB.Text & "','" & StudMailTB.Text & "','" & CosCB.Text & "','" & EnrolledCB.Text & "','" & ExpiryCB.Text & "')"
cmd.CommandText = strsql
con.Open()
cmd.ExecuteNonQuery()
con.Close()
MsgBox("New Member Added!")
Me.Close()
End Sub
I haven't changed any of strsql because you seem to think the query is ok. Only you would know that. Check the single quotes etc are legal..
For queries containing this many fields, you should be using parameter queries. Once you get used to them, you will use them all the time. They are much easier to read and you can check/set data types as you go.
Steve
|
|
|
|
|
Hi All !!
I am new to VB.NET... I want to make the characters in the text of TextBox control read only... That is, those characters should not be replaced by any other character, or can not be editable... So is there any property or method that can be implemented to the charactres/text(string) of textbox's text ??
Well, very clearly, I don't want to make the whole Textbox uneditable. I just want some part of input and moreover already set text in the textbox uneditable, as we can see as par as in MaskedTextBox, for e.g. in date format, we have "/" separator uneditable. So I just want to make the text uneditable.
Expecting the responses.
Thanks,
Prodigy201
|
|
|
|
|
my 1 i used the property table of the textbox
scroll and go find the read-only option n set it to true
|
|
|
|
|
Hi !!
Thanks for the response !
Well, I don't want to make whole textbox control as readonly, but I just want to make some part of text in the textbox readonly, i.e to make some part of the text uneditable, as we can find it in MaskedTextBox control. for e.g. "/" separator in date format (found in mask properties of MaskedTextBox) as uneditable character. So is there any property or method that can be used to make this functionality?
Expecting response
Thanks,
Prodigy201
|
|
|
|
|
There is no property in the TextBOx that will do this for you.
You'll either have to use the MaskedTextBox control to get what you want (easiest option), or create your own version of the control (much more difficult).
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You can use the KeyPress event of your textbox field to override the characters that are entered, forcing the character at a certain position in the string to be a particular character. You can also limit the number of characters enetered. The following example is for a date entry field:
With YourTextBox
If Len(.Text) >= 10 And Not e.KeyChar = ChrW(8) Then
MsgBox("Maximum number of input characters is 10!", _
MsgBoxStyle.Information, "Invalid Data Input")
Exit Sub
ElseIf Len(.Text) = 2 And Not e.KeyChar = ChrW(8) And Not e.KeyChar = ChrW(47) Then
.Text = .Text & "/"
.Select(.Text.Length, 0)
ElseIf Len(.Text) = 5 And Not e.KeyChar = ChrW(8) And Not e.KeyChar = ChrW(47) Then
.Text = .Text & "/"
.Select(.Text.Length, 0)
Else
End If
End With
I use something similar to this to validate entry on all my fields. It is used in combination with the TextChanged and Validating events. I have stripped out code for setting errorproviders etc..
Steve
|
|
|
|
|
i wanna do invoice with vb in the report.. but i only know how to show all the list of the report in it.
How do i only show the specific number according to my form choosen?
Like when user choose to see the no.1 invoice then it will show it out and print out...?
|
|
|
|
|
hie ,
i need to make a listview with a popup menu BUT i need to show the "properties" of the selected item like in explorer.Problem is with this code :
Private Sub ListView2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)<br />
<br />
If Button = vbRightButton Then<br />
'If ListView2.SelectedItem = ListView2.HitTest(x, y) Then<br />
PopupMenu mnuMyMenu, vbPopupMenuRightButton<br />
'End If<br />
End If<br />
End Sub
With the 'If ListView2.Selec.... commented i just get a popup menu no matter where i click , like white space.Also if the user cliked item1 , then right-clicked in any white space.. the popup shows up with the listview SELECTED property set to item1 i Need to show the menu ONLY if the user click an ITEM!! but then with comments removed i get a runtime error 91 , object variable or with block nt set ONLY IF I CLICK A WHITE SPACE>> if i click an ITEM EVERYTHING RUNS SMOOTHLY!!
Option 2: i found http://vb-helper.com/howto_listview_right_click_header.html[^] site , it uses a VC type procedure , i do know VC , BUT its for getting a context menu on the header of the listview. The message the programm looks for is "WM_PARENTNOTIFY" and then a "WM_RBUTTONDOWN" wParam.Now I DONT KNOW THE MESSAGE for items!!
Could some one help me HERE!!
Gideon
|
|
|
|
|
ok , this is quite embarassing .. .. all i did was add a set and everything worked!!! (yes i did declare the variable!)
anyway , heres the code so no one else makes any mistakes!
Private Sub ListView2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)<br />
If Button = 2 Then<br />
Set lst = ListView2.HitTest(x, y)<br />
If Not lst Is Nothing Then<br />
PopupMenu mnuMain, vbPopupMenuRightButton<br />
End If<br />
End If<br />
End Sub
1. Use it ONLY in the MOUSEUP event
2. I dont think vbPopupMenuRightButton makes much of a difference , i any1 knows tell me!!
3. DONT FORGET SET
Hope that helps some1
Gideon
|
|
|
|
|
I'm writing a little program just for personal use which has all my favourite programs and accessories links on it, sort of like a second taskbar if you get me.
All is going well, however now I want to make my program so its always on top, but besides that I want to make it so no other windows of any other program are going behind it. E.g How all program windows stop where the taskbar starts, they dont go behind the actual taskbar. My program loads on the right side of my screen, just like the new vista sidebar does, or google desktop sidebar. Any ideas as how I can achieve this?
If I havent explained correctly myself please let me know.
In a nutshell, I want other programs running to 'bud up' to the side of my 'sidebar', instead of just going completely behind it while it is always on top.
Regards,
litestep23.
|
|
|
|
|
Hi all,
I'm having a weird problems with my email.
I'm using System.web.mail namespace to send the email.
Everything went well until I tried to import the message body from microsoft words.
What I did was change the message body with the imported text from word.
The message example is like this
Dear Dr. Who,
This is just a test. Please click the following link.
www.testing.com
You are given a password
Thank you,
Eagertolearn
When I test it to send it to hotmail, yahoo and gmail, it's showing only the "given a password" line. Everything else is not shown. When I tried to send it to company's email, it's working really well. Anyone knows what i'm doing wrong?
-- modified at 19:37 Wednesday 2nd August, 2006
|
|
|
|
|
Could it be that the message contains XML tags and it's being stripped ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Nope, it's plain text.
|
|
|
|
|
but you mentioned that you imported this from Microsoft Word? It adds a lof of its own formatting. you should try this in notepad and then try.
Thanks.
Vani
|
|
|
|
|
Have you looked at what Word puts into an HTML document? It throws in tons of stuff that is useless to you but Word needs in case it needs to open the document again and edit it. You'd be better off writing your HTML email from scratch and, from what you posted here, you can do it in less than 10 lines...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I don't think it's an HTML document. I import it as text and i don't see any other text other than the message itself.
Yeah, I think I'm going to try to write from scratch.
Thanks Dave
|
|
|
|
|
i'm a beginner in VB.Net, i've already connected my project through sql server 2000. Also created tables now i want to add records n retrive records from the Tables.
I've created a registration form for which i want data to be saved into the tables... please help me out with the appropriate method for fetching data from sql tables.
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
You can use SqlDataAdapter or SqlCommand objects to place your data in your DataSet.
The DataAdapter has the advantage that you can use the same object to update your database tables.
Search your help files for information on these objects.
Steve
-- modified at 13:52 Wednesday 2nd August, 2006
|
|
|
|
|
i want the code for fetchin recods ... Plzz tell me the code
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
It's not that easy!
First you need to create a connection object and set it's properties, connection string etc.
Then you need to setup your dataset tables and relationships/constraints etc
Then you can create your DataAdapters or command objects to retrieve your data and place it in your dataset. From there, you can bind it to your form controls.
If you are a beginner, as you stated, you will learn more by finding out for yourself by reading the help topics in Visual Studio or MSDN.
I will help you with any particular thing you don't understand but it is far too complicated to just give you all the code for what you ask.
You have to do some of the work yourself!
Steve
|
|
|
|
|
i've done all the necessary things just binding the records is left where i'm facing the prob i already used MSDN for help.. only thing is bindin .. i've created a Table named info where name, rollno,fname,sex,marital status etc r the fields.. i've also written the code in Module n database connection is already established now wat code shud i write to bind the form with tables...
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|
You need to do something like this:
Private Sub POPULATE_Controls
With YourDataSet.Tables("YourTable").Rows _
(Me.BindingContext(YourDataSet, "YourTable").Position)
ControlName.Text = IIf(IsDBNull(.Item("YourFieldName")), "", _
.Item("YourFieldName"))
'Repeat for each field/control
End With
End Sub
Unless you are doing it all in the designer (datasets etc) then you can bind through the properties window. I always do it in code.
To view the next record, you will need to create your navigation buttons and adjust the BindingContext position, then call POPULATE_Controls again.
Steve
-- modified at 15:48 Wednesday 2nd August, 2006
|
|
|
|
|
thnx STEVE i got it now.
Paritosh Tripathi
B.Tech. (C.S.)
|
|
|
|
|