get a msg that "ID ALREADY EXIST"

ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
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???????/
0
ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
[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
0
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
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...
0
ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
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
0
lionaneesh's Avatar, Join Date: Mar 2010
Invasive contributor
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!!
0
ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
no i want only in vb
0
shyam_oec's Avatar, Join Date: Nov 2007
Contributor
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
0
ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
yeah but i not sure where to give the statement and i hav tried everything
0
shyam_oec's Avatar, Join Date: Nov 2007
Contributor
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.
0
ranchani's Avatar, Join Date: Jun 2010
Go4Expert Member
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