Programming for Everybody
Simple and Effective: Creating Invoices with Crystal Reports in C# With Source code
Video MS Access VBA Tutorial: Building a Data Entry Form with ListBox
MS Access VBA Tutorial: Building a Data Entry Form with ListBox
Subscribe to @programmingforeverybody
https://www.youtube.com/@programmingforeverybody/?sub_confirmation=1
Keywords:
Step-by-Step Guide: Creating a ListBox-Driven Data Entry Form in Access
Learn How to Use ListBoxes for Dynamic Data Input in MS Access
Master MS Access VBA: Design a Data Entry Form with ListBox Options
Creating a User-Friendly Data Entry Form in Access Using ListBoxes
Keyword-Rich Titles:
MS Access VBA ListBox Data Entry Form Tutorial
How to Make a ListBox-Based Data Entry Form in Access
Access VBA: Dynamic Data Entry with ListBoxes
Learn Access VBA: Create a ListBox-Driven Data Entry Form
Access VBA Tutorial: ListBox Data Validation and Input
Boost Your Access Skills: Create a Dynamic ListBox Data Entry Form
Simplify Data Entry in Access: Use ListBoxes Effectively
Master MS Access: Build a Powerful ListBox-Driven Data Entry Form
Take Your Access Game to the Next Level: Learn ListBox Data Entry
Want to Impress Your Boss? Create a Custom ListBox Data Entry Form
Very simple Code insert button VBA without duplicate values in MS Access VBA with source code
Source Code in video
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strsql As String
Set dbs = OpenDatabase("H:\products.accdb")
Set rst = dbs.OpenRecordset("Select product From Table1 Where product = '" & Me.Text0.Value & "' ")
If rst.RecordCount > 0 Then
MsgBox ("This Product exists before")
Else
strsql = "Insert Into Table1(product)Values( '" & Me.Text0.Value & "' )"
dbs.Execute (strsql)
MsgBox ("The product inserted successfully")
End If
rst.Close
dbs.Close
c# tutorial for beginners: How to store images update and delete in sql database with 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.SqlClient;
using System.IO;
namespace Images
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection("Data source=.;Initial catalog=images3;Integrated Security = true");
SqlCommand cmd;
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Select image(*.JpG; *.png; *.Gif)|*.JpG; *.png; *.Gif";
if (openFileDialog1.ShowDialog()== DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(openFileDialog1.FileName);
}
}
private void button2_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Insert Into table1(name_image,image1)Values(@name_image,@image1)", conn);
cmd.Parameters.AddWithValue("name_image", textBox1.Text);
MemoryStream memstr = new MemoryStream();
pictureBox1.Image.Save(memstr, pictureBox1.Image.RawFormat);
cmd.Parameters.AddWithValue("image1", memstr.ToArray());
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
MessageBox.Show("Data Inserted Successfully");
load_data();
}
private void load_data()
{
cmd = new SqlCommand("Select * from table1 order by id desc", conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable dt = new DataTable();
dt.Clear();
da.Fill(dt);
dataGridView1.RowTemplate.Height = 75;
dataGridView1.DataSource = dt;
DataGridViewImageColumn pic1 = new DataGridViewImageColumn();
pic1 = (DataGridViewImageColumn)dataGridView1.Columns[2];
pic1.ImageLayout = DataGridViewImageCellLayout.Stretch;
}
private void Form2_Load(object sender, EventArgs e)
{
load_data();
}
private void dataGridView1_Click(object sender, EventArgs e)
{
id1.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString();
textBox1.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
MemoryStream ms = new MemoryStream((byte[])dataGridView1.CurrentRow.Cells[2].Value);
pictureBox1.Image = Image.FromStream(ms);
}
private void button3_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Update table1 Set name_image = @name_image,image1=@image1 Where id=@id", conn);
cmd.Parameters.AddWithValue("name_image", textBox1.Text);
MemoryStream memstr = new MemoryStream();
pictureBox1.Image.Save(memstr, pictureBox1.Image.RawFormat);
cmd.Parameters.AddWithValue("image1", memstr.ToArray());
cmd.Parameters.AddWithValue("id", id1.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
load_data();
}
private void button4_Click(object sender, EventArgs e)
{
cmd = new SqlCommand("Delete from table1 where id=@id", conn);
cmd.Parameters.AddWithValue("id", id1.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
load_data();
pictureBox1.Image = null;
textBox1.Text = "";
id1.Text = "";
}
}
}
Code VB.Net SQL query combine two columns that contain different data type and display in ComboBox
Imports System.Data.SqlClient
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim conn As New SqlConnection("Data Source=.;Initial Catalog=products;integrated Security=true")
'conn.Open()
Dim cmd As New SqlCommand("Select id, '(' + Cast(id As nvarchar(50))+ ')' + item_product As products from names_products", conn)
Dim da As New SqlDataAdapter(cmd)
Dim dt As New DataTable
da.Fill(dt)
With ComboBox1
.DataSource = dt
.DisplayMember = "products"
.ValueMember = "id"
.Text = "Select Product"
End With
End Sub
End Class