Hello Friends
I am newbie To Vb.net. i am building an vb.net 2005 application with ms-access 2000 as back end for practice.
i just want to know that suppose user entering new data to the database if this record already exist then user should know that how can i do that i m giving my add button code to you all
If TextBox1.Text = "" Then
MessageBox.Show("Please Write Values In Text Boxes proper")
ElseIf TextBox2.Text = "" And TextBox3.Text = "" And TextBox4.Text = "" And TextBox5.Text = "" Then
MessageBox.Show("Please Write Values In Text Boxes proper")
ElseIf TextBox2.Text.IndexOfAny("0123456789") = -1 And TextBox3.Text.IndexOfAny("0123456789") = -1 And TextBox4.Text.IndexOfAny("0123456789") = -1 Then
MessageBox.Show("Please Write Numeric Expression")
Else
Mycn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\ameya\WindowsApplication2\portfolio.mdb")
Mycn.Open()
SQLstr = String.Format("INSERT INTO p1 VALUES('{0}','{1}','{2}','{3}','{4}')", TextBox1.Text, TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox5.Text)
Command = New OleDbCommand(SQLstr, Mycn)
Command.ExecuteNonQuery()
MessageBox.Show("New Record Added To your Portfolio")
Mycn.Close()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End If
End Sub
the first value that is script_name that is my primary key of the table. Please Guys Help me
Thanks In advance!!!