Click here to Skip to main content
15,917,795 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: code to find max orderno Pin
Eddy Vluggen16-Aug-09 3:02
professionalEddy Vluggen16-Aug-09 3:02 
GeneralRe: code to find max orderno Pin
Zizo_nis16-Aug-09 3:50
Zizo_nis16-Aug-09 3:50 
GeneralRe: code to find max orderno Pin
Eddy Vluggen16-Aug-09 5:05
professionalEddy Vluggen16-Aug-09 5:05 
GeneralRe: code to find max orderno Pin
AjitMourya16-Aug-09 19:58
AjitMourya16-Aug-09 19:58 
GeneralRe: code to find max orderno Pin
Eddy Vluggen16-Aug-09 21:10
professionalEddy Vluggen16-Aug-09 21:10 
GeneralRe: code to find max orderno Pin
AjitMourya16-Aug-09 19:30
AjitMourya16-Aug-09 19:30 
AnswerRe: code to find max orderno Pin
Johan Hakkesteegt16-Aug-09 21:01
Johan Hakkesteegt16-Aug-09 21:01 
QuestionVB Sql check and insert if then command Pin
Brav0116-Aug-09 0:56
Brav0116-Aug-09 0:56 
HI
I am new to coding and I was in need of a little help.

I have a contacts form and there is a textbox "tbNewContact.Text" and two buttons. When one buttone is pressed I was wanting the following to happen. An sql connection has been opened at form_load.

When the user enters a contacts name it does a check on the database table. If it returns any rows then it displays a message.
If not rows returned then it will submitted the contact to the SQL database.

But it does not work. I get the message "Contacted Added" but nothing has been.

If the code is cra then sorry like i said Im new to this. Laugh | :laugh:


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddContact.Click
    'Check Contacts
    Dim SQLSearch As SqlCommand = sqlconn.CreateCommand
    Dim sqlinsert As SqlCommand = sqlconn.CreateCommand
    SQLSearch.CommandText = "SELECT * FROM Contacts WHERE ContactName = '%" & tbNewContact.Text & "%';"
    Dim SQLDR As SqlDataReader = SQLSearch.ExecuteReader

    If SQLDR.HasRows Then
        MsgBox("That contact name already exists." & tbNewContact.Text & _
                "If you wish to add this contact, please cancel and choose 'Add Existing Contact'", MsgBoxStyle.Information)
        SQLDR.Close()
    Else
        sqlinsert.CommandText = "insert into contacts (contactName) values '%" & tbNewContact.Text & "%';"
        MsgBox("Contact Added")

        Exit Sub
    End If
    SQLDR.Close()

End Sub


Thansk In advance
AnswerRe: VB Sql check and insert if then command Pin
Moreno Airoldi16-Aug-09 1:12
Moreno Airoldi16-Aug-09 1:12 
GeneralRe: VB Sql check and insert if then command Pin
Brav0116-Aug-09 2:02
Brav0116-Aug-09 2:02 
AnswerRe: VB Sql check and insert if then command Pin
Paramu197316-Aug-09 20:20
Paramu197316-Aug-09 20:20 
QuestionUnchecking a checked box... Answered,thanks. Pin
Laser Steve15-Aug-09 6:26
Laser Steve15-Aug-09 6:26 
AnswerRe: Unchecking a checked box Pin
Dave Kreskowiak15-Aug-09 6:45
mveDave Kreskowiak15-Aug-09 6:45 
AnswerRe: Unchecking a checked box... Answered,thanks. Pin
Laser Steve15-Aug-09 7:15
Laser Steve15-Aug-09 7:15 
QuestionComboLost focus problem.? Pin
mdrizwan_115-Aug-09 2:54
mdrizwan_115-Aug-09 2:54 
AnswerRe: ComboLost focus problem.? Pin
riced15-Aug-09 3:04
riced15-Aug-09 3:04 
QuestionOutlook Contact list Read Only Problem Pin
dcdhingra14-Aug-09 23:15
dcdhingra14-Aug-09 23:15 
QuestionGoogle Mapping... Pin
mdrizwan_114-Aug-09 20:09
mdrizwan_114-Aug-09 20:09 
AnswerRe: Google Mapping... Pin
Dave Kreskowiak15-Aug-09 6:42
mveDave Kreskowiak15-Aug-09 6:42 
QuestionHow to Generate data on Crystal Report when Datagridview item is selected Pin
Dambod14-Aug-09 7:50
Dambod14-Aug-09 7:50 
AnswerRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak14-Aug-09 8:10
mveDave Kreskowiak14-Aug-09 8:10 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dambod14-Aug-09 8:25
Dambod14-Aug-09 8:25 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak14-Aug-09 8:35
mveDave Kreskowiak14-Aug-09 8:35 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Paramu197314-Aug-09 19:46
Paramu197314-Aug-09 19:46 
GeneralRe: How to Generate data on Crystal Report when Datagridview item is selected Pin
Dave Kreskowiak15-Aug-09 2:21
mveDave Kreskowiak15-Aug-09 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.