TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Atul Rokade
NA
141
44.1k
write insert query if auto complete text not found data
Mar 18 2016 2:47 AM
Hi,
Im creating one application having following requirment
1. having two text box party code and partycode1
2. both are auto complete text box , if value not found in partycode or partycode1 then message box will open data not found do you want to create a record if user click yes then insert query should be fire at same time
3. next time if user try to search partycode then name should be come as autocomplete and same time partycode1 also generated if name exist with disable mode ,user cant modified partycode textbox as second time , value should show basis on what user search into partycode textbox
4. i wrote code on partycode textchanged event but it is not work which i want exactly so please can you all help me to solve this issue, below code is give
string ab =(txtpartycode.Text);
string bc = txtpartycode1.Text;
con = new OleDbConnection(@" provider=Microsoft.ACE.OLEDB.12.0; Data Source=E:\Database\BillAndReceipt.accdb;Persist Security Info=False;");
con.Open();
string query = "Select Party_Code,Party_Code1 from Billing";
OleDbCommand cmd1 = new OleDbCommand(query, con);
OleDbDataReader dr = cmd1.ExecuteReader();
if (dr.Read())
{
ab = dr[0].ToString();--> exception coming this line index was outside the bounds of the array
bc = dr[1].ToString();
}
else
{
DialogResult dialogResult = MessageBox.Show("Data Not Found Do you want to create?", "Data insert Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (dialogResult == DialogResult.Yes)
{
string SqlString = "Insert Into Billing (Party_Code,Party_Code1)Values (?,?)";
using (OleDbCommand cmd = new OleDbCommand(SqlString, con))
{
con.Open();
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Party_Code", txtpartycode.Text);
cmd.Parameters.AddWithValue("@Party_Code1", txtpartycode1.Text);
int n = cmd.ExecuteNonQuery();
con.Close();
if (n > 0)
{
MessageBox.Show("Data Inserted Successfully", "Data Inserted ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("Data Not inserted", "Data not Inserted ", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}
con.Close();
Reply
Answers (
0
)
how to calculate L * W * H in jquery code
how to update gridview radiobutton data into into database