16-02-19, 12:57 AM
جرب هذه اخي مع تغير مسمى الادوات
PHP كود :
Public Function add_TBL_Products() As Boolean
Dim Cmdf As New OleDbCommand
Dim CommandTextf As String
Dim CommandTexts As String
Dim dtf As New DataTable
CommandTextf = "insert into TBL_Products ( "
CommandTexts = " values( "
CommandTextf &= "Pro_Code"
CommandTexts &= "@Pro_Code "
CommandTextf &= ",Pro_Name"
CommandTexts &= ",@Pro_Name "
CommandTextf &= ",Pro_Price"
CommandTexts &= ",@Pro_Price "
CommandTextf &= ",Pro_Moms"
CommandTexts &= ",@Pro_Moms "
CommandTextf &= ",Pro_Totalt"
CommandTexts &= ",@Pro_Totalt "
CommandTextf &= " ) "
CommandTexts &=" ) "
With Cmdf
.Connection = con
.CommandType = CommandType.Text
' .CommandText = "insert into TBL_Products (Pro_Code,Pro_Name,Pro_Price,Pro_Moms,Pro_Totalt) values(@Pro_Code ,@Pro_Name ,@Pro_Price ,@Pro_Moms ,@Pro_Totalt )"
.CommandText = CommandTextf & CommandTexts
.Parameters.Clear()
With Cmdf.Parameters
.AddWithValue("@", AdminID).DbType = DbType.Int64
If TXT_Pro_Code.Text.Trim= "" Then
.AddWithValue("@Pro_Code", DBNull.Value).DbType = DbType.Int32
Else
.AddWithValue("@Pro_Code",TXT_Pro_Code.Text).DbType = DbType.Int32
End If
If TXT_Pro_Name.Text.Trim= "" Then
.AddWithValue("@Pro_Name", DBNull.Value).DbType = DbType.String
Else
.AddWithValue("@Pro_Name",TXT_Pro_Name.Text).DbType = DbType.String
End If
If TXT_Pro_Price.Text.Trim= "" Then
.AddWithValue("@Pro_Price", DBNull.Value).DbType = DbType.Decimal
Else
.AddWithValue("@Pro_Price",TXT_Pro_Price.Text).DbType = DbType.Decimal
End If
If TXT_Pro_Moms.Text.Trim= "" Then
.AddWithValue("@Pro_Moms", DBNull.Value).DbType = DbType.Decimal
Else
.AddWithValue("@Pro_Moms",TXT_Pro_Moms.Text).DbType = DbType.Decimal
End If
If TXT_Pro_Totalt.Text.Trim= "" Then
.AddWithValue("@Pro_Totalt", DBNull.Value).DbType = DbType.Decimal
Else
.AddWithValue("@Pro_Totalt",TXT_Pro_Totalt.Text).DbType = DbType.Decimal
End If
End With
End With
If con.State = ConnectionState.Open Then con.Close()
con.Open()
Dim Affected As Int32 = cmdf.ExecuteNonQuery
con.Close()
If Affected = 1 Then
'هذا يعني نجاح العملية
Return True
End If
Return False
End Function

