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
Aruljothy Sundaramoorthy
NA
311
48.7k
How to Retrieve OLedb data and show it to MessageBox
Apr 23 2018 12:33 PM
Here i did some code to retieve the data from my Oledb and show it via MessageBox But i didn't get the exact output:
---------------------------------------------------------------
Code:
---------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;
namespace AutomaticPrescriptionSystem
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
OleDbConnection con1 = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\\db\\Pres.mdb;");
OleDbCommand cmd1 = con1.CreateCommand();
con1.Open();
cmd1.CommandText = "Select * From advice Where bp='" + this.textBox1.Text + "' and heartrate='" + this.textBox2.Text + "'";
cmd1.Connection = con1;
// cmd1.ExecuteNonQuery();
OleDbDataReader mReader = cmd1.ExecuteReader();
int count = 0;
while (mReader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Advice " + cmd1);
}
else
{
MessageBox.Show("incorrect");
}
}
catch (Exception)
{
Console.WriteLine("no connection");
}
}
}
}
Reply
Answers (
1
)
C# how to insert image ????
C# code to auto copy new photos from connected Iphone?