将文本框值插入Access数据库 [英] Inserting textbox value into access database

查看:127
本文介绍了将文本框值插入Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用vb.net将文本框值或数据插入到Access数据库2007中?

How to insert textbox vaule or data into access database 2007 using vb.net?

推荐答案

这是VB.NET中的代码:

This is the code in VB.NET:

Dim constr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\your_DataBase_Name.accdb;"
Dim Con As OleDbConnection = New OleDbConnection(constr)
Con.Open
Dim com As OleDbCommand = New OleDbCommand
com.Connection = Con
com = New OleDbCommand("your insert command here", Con)
Dim Num As Integer = com.ExecuteNonQuery
If (Num <> 0) Then
    MessageBox.Show("Record Successfully Added....", "Add Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Me.Close
Else
    MessageBox.Show("Record is not Added....", "Add Record Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If


简单...

只是谷歌它...你会找到答案的....

这是C#.net
中的代码
it seems to be a simple...

just google it ... you will find the answer....

this is the code in C#.net

string constr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\your_DataBase_Name.accdb;";
                   OleDbConnection Con = new OleDbConnection(constr);
                   Con.Open();
                   OleDbCommand com = new OleDbCommand();
                   com.Connection = Con;
                   com = new OleDbCommand("your insert command here", Con);
                   int Num=com.ExecuteNonQuery();
                   if (Num != 0)
                   {
                       MessageBox.Show("Record Successfully Added....", "Add Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                       this.Close();
                   }
                   else
                   {
                       MessageBox.Show("Record is not Added....", "Add Record Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                   }


请参见 http://www.startvbdotnet.com/ado/msaccess .aspx [ ^ ]的教程.
See http://www.startvbdotnet.com/ado/msaccess.aspx[^] for a tutorial.


这篇关于将文本框值插入Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆