get a msg that "ID ALREADY EXIST"

Go4Expert Member
23Feb2011,23:58   #1
ranchani's Avatar
i am a beginner, i don't how to give command

how to display a msgbox that " ID already exist " for a given textbox

should i use getfocus if so how????? or is there another way???????/
Go4Expert Member
24Feb2011,00:02   #2
ranchani's Avatar
[quote=ranchani;79805]i am a beginner, i don't how to give command

how to display a msgbox that " ID already exist " for a given textbox

should i use getfocus if so how????? or is there another way???????

in vb
Invasive contributor
24Feb2011,11:22   #3
lionaneesh's Avatar
1. Please try and edit your previous post rather than...Just posting a new one..
2. use the quote tags properly..
3. Please clear you question...You want a alert box or a simple error text...
Go4Expert Member
24Feb2011,20:04   #4
ranchani's Avatar
Quote:
Originally Posted by lionaneesh View Post
1. Please try and edit your previous post rather than...Just posting a new one..
2. use the quote tags properly..
3. Please clear you question...You want a alert box or a simple error text...
anything is fine as long as it works
Invasive contributor
24Feb2011,20:56   #5
lionaneesh's Avatar
Quote:
Originally Posted by ranchani View Post
anything is fine as long as it works
In VB because i can make it in javascript if you are OK with it!!
Go4Expert Member
25Feb2011,20:38   #6
ranchani's Avatar
no i want only in vb
Contributor
26Feb2011,17:48   #7
shyam_oec's Avatar
Quote:
Originally Posted by ranchani View Post
no i want only in vb
Hi,
You can use MsgBox function,have you tried that ?
shabbir like this
Go4Expert Member
26Feb2011,21:14   #8
ranchani's Avatar
yeah but i not sure where to give the statement and i hav tried everything
Contributor
26Feb2011,21:43   #9
shyam_oec's Avatar
Quote:
Originally Posted by ranchani View Post
yeah but i not sure where to give the statement and i hav tried everything
If you are not sure where to give the statement then can you show us your code?
Sorry to say, if you had tried everything you would have solved that problem.I do'nt think that you have tried everything.
Go4Expert Member
27Feb2011,00:17   #10
ranchani's Avatar
Code:
Imports System.Data
Imports System.Data.OleDb

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack = True Then
            Reset()
        End If
    End Sub


Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click

        Dim con As New OleDbConnection
        Dim com As New OleDbCommand
        Dim sqlString, STID, STNAME, AGE, ADMNO, FNAME, MNAME, BATCH, ADDRESS, PHNO, MOBNO, EMAIL As String

        STID = TextBox1.Text
        STNAME = TextBox2.Text
        AGE = TextBox3.Text
        ADMNO = TextBox4.Text
        FNAME = TextBox5.Text
        MNAME = TextBox6.Text
        BATCH = TextBox7.Text
        ADDRESS = TextBox8.Text
        PHNO = TextBox9.Text
        MOBNO = TextBox10.Text
        EMAIL = TextBox13.Text


        con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Varsha\My music\Visual Studio 2005\WebSites\PSA\App_Data\student.mdb")
        con.Open()
        sqlString = "insert into Table1 values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "','" & TextBox10.Text & "','" & TextBox13.Text & "')"
        com = New OleDbCommand(sqlString, con)
        com.ExecuteNonQuery()
        MsgBox("Data is successfully entered")
        con.Close()


    End Sub

Last edited by shabbir; 27Feb2011 at 09:43.. Reason: Code blocks