18-02-20, 09:08 PM
(18-02-20, 04:44 PM)asemshahen5 كتب : الكود مع إضافة 0 كقيمة افتراضية في الاعمدة المضافة :
PHP كود :
Sub AlterTableX1(field_row As ListBox)
Dim intLoop As Integer
Dim strSQL As String
Dim strSQL1 As String
Dim sReturn As String = ""
For intLoop = 0 To field_row.Items.Count - 1
Dim drSelectedItem As DataRowView = field_row.Items(intLoop)
sReturn = drSelectedItem.Item(0).ToString
strSQL = "ALTER TABLE Emp_Sal ADD " & _
sReturn & " LONG DEFAULT '0' NOT NULL" 'DECIMAL (28,2)
ExcuteNoneQury(strSQL)
strSQL1 = "ALTER TABLE tbl_General ADD " & _
sReturn & " LONG DEFAULT '0' NOT NULL " 'DECIMAL (28,2)
ExcuteNoneQury(strSQL1)
Dim strSql2 As String = "update Emp_Sal Set " & sReturn & "=0"
ExcuteNoneQury(strSql2)
Dim strSql3 As String = "update tbl_General Set " & sReturn & "=0"
ExcuteNoneQury(strSql3)
Next
MsgBox("تمت الإضافة بنجاح", MsgBoxStyle.Information, "البرنامج ")
End Sub
Sub ExcuteNoneQury(strSQL As String)
Dim cn As New OleDb.OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\TBLCO.mdb")
Dim Cmd As New OleDb.OleDbCommand(strSQL, cn)
If cn.State = ConnectionState.Closed Then cn.Open()
Cmd.ExecuteReader()
If cn.State = ConnectionState.Open Then cn.Close()
End Sub
الف الف الف شكر وربنا يجعله فى ميزان حسناتك تم حل المشكلة والكود يعمل بنجاح
