Programming for Everybody: programming for everybody
Showing posts with label programming for everybody. Show all posts
Showing posts with label programming for everybody. Show all posts

connect access database with visual studio 2026 (vb.net & C#) without errors

 


In this video, I walk through three complex and very common problems developers face when connecting a Visual Studio application to an Access database. Even though I was using Microsoft Office 365, these issues still occurred. This proves that the problem is not about outdated software — but about architecture conflicts, missing providers, and incorrect setup. If this video helped you solve your problem, consider liking and subscribing for more practical tutorials. #programming_for_everybody #programming_for_everybody_access #programmigforeverybody #visualstudioaccess #csharpaccess #vbdotnet 🚨 Problems Covered in This Video 1️⃣ ACE.OLEDB Provider Not Installed You may encounter this error: “The Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine” 2️⃣ 32-bit vs 64-bit Conflict (Critical Issue) One of the most confusing problems: “You cannot install the 64-bit version because 32-bit Office products are installed…” Even with Office 365, the mismatch between 32-bit Office and 64-bit tools causes major issues. 3️⃣ Failed Connection in Data Source Wizard Visual Studio may show: “Failed to open a connection to the database” ✅ What You Will Learn How to fix ACE.OLEDB provider errors How to resolve 32-bit vs 64-bit conflicts How to properly install Access Database Engine How to configure your project correctly How to successfully connect VB.NET / C# with Access 💡 Final Result By the end of this video, the application connects successfully and loads data without errors. 🔥 Why This Video Matters These issues can happen even on modern environments like Office 365, and many developers waste hours trying random solutions. This video gives you a clear, structured, and real-world fix. 🧠 Pro Tip Always ensure: Bit compatibility (32-bit vs 64-bit) Correct OLEDB provider Proper environment configuration






Connect VB.NET to Local SQL Database in Visual Studio 2026 (With Source Code)



Imports System.Data.SqlClient
Public Class Form1
Dim conn2 As New SqlConnection("Data Source=(localdb)\MSSQLLocalDB;initial catalog=database2;Integrated Security=True")
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim conn As New SqlConnection("Data Source=(localdb)\MSSQLLocalDB;Integrated Security=True")
Dim strsql As String = "If Not Exists(Select name from sys.databases Where name='database2')" &
" begin create database database2 select 1 end" &
" else begin select 0 end"
Dim cmd As New SqlCommand(strsql, conn)
conn.Open()
Dim result As Integer = Convert.ToInt32(cmd.ExecuteScalar())
If result = 1 Then
MessageBox.Show("Database created Successfully")
Else
MessageBox.Show("Database already exists")
End If
conn.Close()
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim strsql As String = "If Not Exists(Select name From sys.tables Where name='students') " &
"begin create table students(id int primary key identity(1,1)," &
"name1 varchar(50) Not Null," &
"phone varchar(50) Not Null," &
"date1 date Not Null) Select 1 end " &
" else begin select 0 end"
Dim cmd As New SqlCommand(strsql, conn2)
conn2.Open()
Dim result As Integer = Convert.ToInt32(cmd.ExecuteScalar())
If result = 1 Then
MessageBox.Show("Table created Successfully")
Else
MessageBox.Show("Table already exists")
End If
conn2.Close()

End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
load_data()
End Sub
Private Sub load_data()
conn2.Open()
Dim da As New SqlDataAdapter("Select * From students", conn2)
Dim dt As New DataTable
da.Fill(dt)
DataGridView1.DataSource = dt
conn2.Close()
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
DateTimePicker1.Value = Now()
Button4.Enabled = True
End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim cmd As New SqlCommand("Insert Into students(name1,phone,date1)Values(@name1,@phone,@date1)", conn2)
cmd.Parameters.AddWithValue("name1", TextBox1.Text.Trim)
cmd.Parameters.AddWithValue("phone", TextBox2.Text.Trim)
cmd.Parameters.AddWithValue("date1", DateTimePicker1.Value.ToString)
conn2.Open()
cmd.ExecuteNonQuery()
conn2.Close()
Button4.Enabled = False
load_data()
End Sub 

End Class 

visual Basic.net programmer Registration Form in VB.net



Imports System.IO

Imports System.Data.SqlClient

Public Class Form1

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged

        If CheckBox1.Checked = True Then

            password.UseSystemPasswordChar = False

        Else

            password.UseSystemPasswordChar = True

        End If

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        OpenFileDialog1.ShowDialog()

        image_path.Text = Path.GetDirectoryName(OpenFileDialog1.FileName) & "\" & Path.GetFileName(OpenFileDialog1.FileName)

        PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)

    End Sub


    Private Sub lastname_KeyDown(sender As Object, e As KeyEventArgs) Handles lastname.KeyDown

        If e.KeyCode = Keys.Enter Then

            username.Text = firstname.Text + lastname.Text

        End If

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        If username.Text = "" Then

            MessageBox.Show("Please enter username")

            Return

        End If

        If m1.Checked = False And f1.Checked = False Then

            MessageBox.Show("Please select gender")

            Return

        End If

        Dim conn As New SqlConnection("Data source=.;initial catalog=register2;integrated security=true")

        If conn.State = ConnectionState.Closed Then

            conn.Open()

        End If

        Dim cmd As New SqlCommand("Select username from table1 where username=@username", conn)

        cmd.Parameters.AddWithValue("username", username.Text)

        Dim myreader As SqlDataReader = cmd.ExecuteReader

        If (myreader.Read()) Then

            MessageBox.Show("Username inserted before")

            conn.Close()

            Return

        Else

            conn.Close()


            Dim cmd2 As New SqlCommand("Insert into table1(firstname,lastname,username,password,phone,date_birth,gender,image1)Values(@firstname,@lastname,@username,@password,@phone,@date_birth,@gender,@image1)", conn)

            cmd2.Parameters.AddWithValue("firstname", firstname.Text)

            cmd2.Parameters.AddWithValue("lastname", lastname.Text)

            cmd2.Parameters.AddWithValue("username", username.Text)

            cmd2.Parameters.AddWithValue("password", password.Text)

            cmd2.Parameters.AddWithValue("phone", phone.Text)

            cmd2.Parameters.AddWithValue("date_birth", date_birth.Text)



            Dim gender_v As Boolean

            If m1.Checked = True Then

                gender_v = 1

            End If

            If f1.Checked = True Then

                gender_v = 0

            End If


            cmd2.Parameters.AddWithValue("gender", gender_v)

            cmd2.Parameters.AddWithValue("image1", image_path.Text)


            If conn.State = ConnectionState.Closed Then

                conn.Open()

            End If

            cmd2.ExecuteNonQuery()

            conn.Close()

            MessageBox.Show("Data inserted Successfully")

        End If

    End Sub

End Class

 

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


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 = "";

        }

    }

}


VB.net - load data from SQL database format datagridview and use statement with

 


Contents🎞
Load data from SQL database 00:56
Delete the last blank row and Prevent user to add rows 03:59
Fill the width of the available display area in datagridview 04:35
Change font column headers (Type - size - Style) 05:25
Change Colors column headers (Backcolor - Forecolor) 06:40
Change alignment column headers 08:51
Change font columns (Type - size) 09:47
Change alignment columns 10:46
With...End With Statement 11:35


Visual Basic.net: how to calculate third column in a datagridview as product of two other columns

 

Public Class Form8

    Private Sub Form8_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim table As New DataTable("table")

        table.Columns.Add("ID", Type.GetType("System.Int32"))

        table.Columns.Add("Name", Type.GetType("System.String"))

        table.Columns.Add("Arabic", Type.GetType("System.Double"))

        table.Columns.Add("English", Type.GetType("System.Double"))

        table.Columns.Add("Sum", Type.GetType("System.Double"))

       DataGridView1.DataSource = table

    End Sub

    Private Sub DataGridView1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellEndEdit

        For i As Integer = 0 To DataGridView1.Rows.Count - 1

            Dim a1 As Double = DataGridView1.Rows(i).Cells(2).Value

            Dim b1 As Double = DataGridView1.Rows(i).Cells(3).Value

            Dim c1 As Double = a1 + b1

            DataGridView1.Rows(i).Cells(4).Value = c1

        Next

    End Sub

    Private Sub DataGridView1_DefaultValuesNeeded(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles DataGridView1.DefaultValuesNeeded

        e.Row.Cells("Arabic").Value = "0"

        e.Row.Cells("English").Value = "0"

        e.Row.Cells("Sum").Value = "0"

    End Sub