using System;
using System.Data;
using System.Data.OleDb;namespace Materiel {
/// <summary>
/// 物料
/// </summary>
public class Item {
public Item() {} /// Public constants for column positions on the Item table.
public const int Item_no = 0;
public const int Note = 1;
public const int Unit = 2; /// <summary>
/// Inserts a record into the Item table.
/// </summary>
public static void Insert(string item_no, string note, string unit) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemInsert";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no));
command.Parameters.Add(new OleDbParameter("@note", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "note", DataRowVersion.Proposed, note));
command.Parameters.Add(new OleDbParameter("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "unit", DataRowVersion.Proposed, unit)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Updates a record in the Item table.
/// </summary>
public static void Update(string item_no, string note, string unit) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemUpdate";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no));
command.Parameters.Add(new OleDbParameter("@note", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "note", DataRowVersion.Proposed, note));
command.Parameters.Add(new OleDbParameter("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "unit", DataRowVersion.Proposed, unit)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Deletes a record from the Item table by a composite primary key.
/// </summary>
public static void Delete(string item_no) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemDelete";
command.CommandType = CommandType.StoredProcedure; // Create and append the parameters
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Selects a single record from the Item table.
/// </summary>
public static IDataReader Select(string item_no) {
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemSelect";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no)); // Open the connection, execute the query, and return the result
connection.Open();
return command.ExecuteReader(CommandBehavior.CloseConnection);
}
} catch {
// Close the connection object and rethrow the exception
connection.Close();
throw;
}
}
/// <summary>
/// Selects all records from the Item table.
/// </summary>
public static IDataReader SelectAll() {
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemSelectAll";
command.CommandType = CommandType.StoredProcedure; // Open the connection, execute the query, and return the result
connection.Open();
return command.ExecuteReader(CommandBehavior.CloseConnection);
}
} catch {
// Close the connection object and rethrow the exception
connection.Close();
throw;
}
}
/// <summary>
/// 查询所有的物料
/// </summary>
public static DataTable SelectItem()
{
DataTable table = new DataTable("Item");
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try
{
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Item",connection);
adapter.Fill(table);
}
catch
{
// Close the connection object and rethrow the exception
connection.Close();
throw new Exception("数据查询失败!");
}
return table;
}
/// <summary>
/// 查询所有的物料
/// </summary>
public static DataTable OneItem(string strItemNo)
{
DataTable table = new DataTable("Item");
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try
{
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Item WHERE Item_no = '" + strItemNo.Replace("'","''") + "'",connection);
adapter.Fill(table);
}
catch
{
// Close the connection object and rethrow the exception
connection.Close();
throw new Exception("数据查询失败!");
}
return table;
}
}
}
using System.Data;
using System.Data.OleDb;namespace Materiel {
/// <summary>
/// 物料
/// </summary>
public class Item {
public Item() {} /// Public constants for column positions on the Item table.
public const int Item_no = 0;
public const int Note = 1;
public const int Unit = 2; /// <summary>
/// Inserts a record into the Item table.
/// </summary>
public static void Insert(string item_no, string note, string unit) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemInsert";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no));
command.Parameters.Add(new OleDbParameter("@note", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "note", DataRowVersion.Proposed, note));
command.Parameters.Add(new OleDbParameter("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "unit", DataRowVersion.Proposed, unit)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Updates a record in the Item table.
/// </summary>
public static void Update(string item_no, string note, string unit) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemUpdate";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no));
command.Parameters.Add(new OleDbParameter("@note", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "note", DataRowVersion.Proposed, note));
command.Parameters.Add(new OleDbParameter("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, false, 0, 0, "unit", DataRowVersion.Proposed, unit)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Deletes a record from the Item table by a composite primary key.
/// </summary>
public static void Delete(string item_no) {
using (OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString)) {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemDelete";
command.CommandType = CommandType.StoredProcedure; // Create and append the parameters
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no)); // Open the database connection and execute the query
connection.Open();
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// Selects a single record from the Item table.
/// </summary>
public static IDataReader Select(string item_no) {
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemSelect";
command.CommandType = CommandType.StoredProcedure; // Create the parameters and append them to the command object
command.Parameters.Add(new OleDbParameter("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, false, 0, 0, "Item_no", DataRowVersion.Proposed, item_no)); // Open the connection, execute the query, and return the result
connection.Open();
return command.ExecuteReader(CommandBehavior.CloseConnection);
}
} catch {
// Close the connection object and rethrow the exception
connection.Close();
throw;
}
}
/// <summary>
/// Selects all records from the Item table.
/// </summary>
public static IDataReader SelectAll() {
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try {
using (OleDbCommand command = new OleDbCommand()) {
// Initialize the command
command.Connection = connection;
command.CommandText = "saItemSelectAll";
command.CommandType = CommandType.StoredProcedure; // Open the connection, execute the query, and return the result
connection.Open();
return command.ExecuteReader(CommandBehavior.CloseConnection);
}
} catch {
// Close the connection object and rethrow the exception
connection.Close();
throw;
}
}
/// <summary>
/// 查询所有的物料
/// </summary>
public static DataTable SelectItem()
{
DataTable table = new DataTable("Item");
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try
{
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Item",connection);
adapter.Fill(table);
}
catch
{
// Close the connection object and rethrow the exception
connection.Close();
throw new Exception("数据查询失败!");
}
return table;
}
/// <summary>
/// 查询所有的物料
/// </summary>
public static DataTable OneItem(string strItemNo)
{
DataTable table = new DataTable("Item");
OleDbConnection connection = new OleDbConnection(SystemFramework.ApplicationConfiguration.ConnectionString); try
{
OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM Item WHERE Item_no = '" + strItemNo.Replace("'","''") + "'",connection);
adapter.Fill(table);
}
catch
{
// Close the connection object and rethrow the exception
connection.Close();
throw new Exception("数据查询失败!");
}
return table;
}
}
}
解决方案 »
- 高手请指示,初手同努力!
- Datagrid只在筛选范围内选择下页--急在线等...
- 如何用脚本修改lable的tooltip?
- 遇到一难题,关于自定义服务控件的,请高手帮忙????
- 我用asp.net+C#开发的程序,在长时间的测试过程中,我发现DataGrid表单经常要记忆上次的内容,不知怎么办?
- 请教学习.net要看点什么书,请高手推荐几本。
- 如何才能使用HttpContext.Current.User.Identity.Name这个属性
- !!!公司相册问题 !!!
- 求提供一个左右分栏后台管理界面,只要界面.
- 高手们,帮我看一段代码,www.asp.net上的一个分页程序的一部分,急,100分
- 为什么RequiredFieldValidator在有些客户端不起作用?
- 请问怎样把水晶报表拉宽?
Imports System.Data
Imports System.Data.OleDb
Namespace Materiel Public Class Item Public Sub New()
End Sub
Public Const Item_no As Integer = 0
Public Const Note As Integer = 1
Public Const Unit As Integer = 2 Public Shared Sub Insert(ByVal item_no As String, ByVal note As String, ByVal unit As String)
' Using
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
' Inside
' Using
Dim command As OleDbCommand = New OleDbCommand ()
' Inside
command.Connection = connection
command.CommandText = "saItemInsert"
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New OleDbParameter ("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "Item_no", DataRowVersion.Proposed, item_no))
command.Parameters.Add(New OleDbParameter ("@note", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "note", DataRowVersion.Proposed, note))
command.Parameters.Add(New OleDbParameter ("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, False, 0, 0, "unit", DataRowVersion.Proposed, unit))
connection.Open()
command.ExecuteNonQuery()
' End Using
' End Using
End Sub Public Shared Sub Update(ByVal item_no As String, ByVal note As String, ByVal unit As String)
' Using
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
' Inside
' Using
Dim command As OleDbCommand = New OleDbCommand ()
' Inside
command.Connection = connection
command.CommandText = "saItemUpdate"
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New OleDbParameter ("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "Item_no", DataRowVersion.Proposed, item_no))
command.Parameters.Add(New OleDbParameter ("@note", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "note", DataRowVersion.Proposed, note))
command.Parameters.Add(New OleDbParameter ("@unit", OleDbType.VarChar, 10, ParameterDirection.Input, False, 0, 0, "unit", DataRowVersion.Proposed, unit))
connection.Open()
command.ExecuteNonQuery()
' End Using
' End Using
End Sub Public Shared Sub Delete(ByVal item_no As String)
' Using
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
' Inside
' Using
Dim command As OleDbCommand = New OleDbCommand ()
' Inside
command.Connection = connection
command.CommandText = "saItemDelete"
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New OleDbParameter ("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "Item_no", DataRowVersion.Proposed, item_no))
connection.Open()
command.ExecuteNonQuery()
' End Using
' End Using
End Sub Public Shared Function Select(ByVal item_no As String) As IDataReader
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
Try
' Using
Dim command As OleDbCommand = New OleDbCommand ()
' Inside
command.Connection = connection
command.CommandText = "saItemSelect"
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New OleDbParameter ("@Item_no", OleDbType.VarChar, 25, ParameterDirection.Input, False, 0, 0, "Item_no", DataRowVersion.Proposed, item_no))
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
' End Using
Catch generatedExceptionVariable0 As
connection.Close()
Throw
End Try
End Function Public Shared Function SelectAll() As IDataReader
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
Try
' Using
Dim command As OleDbCommand = New OleDbCommand ()
' Inside
command.Connection = connection
command.CommandText = "saItemSelectAll"
command.CommandType = CommandType.StoredProcedure
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
' End Using
Catch generatedExceptionVariable0 As
connection.Close()
Throw
End Try
End Function Public Shared Function SelectItem() As DataTable
Dim table As DataTable = New DataTable ("Item")
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
Try
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter ("SELECT * FROM Item", connection)
adapter.Fill(table)
Catch generatedExceptionVariable0 As
connection.Close()
Throw New Exception ("数据查询失败!")
End Try
Return table
End Function Public Shared Function OneItem(ByVal strItemNo As String) As DataTable
Dim table As DataTable = New DataTable ("Item")
Dim connection As OleDbConnection = New OleDbConnection (SystemFramework.ApplicationConfiguration.ConnectionString)
Try
Dim adapter As OleDbDataAdapter = New OleDbDataAdapter ("SELECT * FROM Item WHERE Item_no = '" + strItemNo.Replace("'", "''") + "'", connection)
adapter.Fill(table)
Catch generatedExceptionVariable0 As
connection.Close()
Throw New Exception ("数据查询失败!")
End Try
Return table
End Function
End Class
End Namespace
地址:http://www.aspalliance.com/aldotnet/examples/translate.aspx
描述:c#翻译为vb.net,提供一个文本框,将你的C#源代码贴进去,就可以帮你翻译成VB.NET语法。