تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
[VB.NET] محتاج كود يقوم بإعادة الترقيم
#1
السلام عليكم

أريد كود يقوم بإعادة الترقيم داخل القاعدة البيانات اذا كانت AutoNumber
القاعدة البيانات نوع Access
مثال بسيط :
1 - احمد
2 - علي

بعد عملية الحذف والاضافة مجددا يصبح :
1- احمد
3- علي

اريد كود يقوم بالترتيب الارقام من جديد
الرد }}}
تم الشكر بواسطة:
#2
Dim s As String = "1"
Dim a As String = "select isnull(max(em_id),0) from employ"
Dim comman As New SqlCommand(a, cn)
ope()

Dim readr As SqlDataReader = comman.ExecuteReader
If readr.Read Then
s = readr.Item(0) + 1
emid.Text = s

End If
clos()
readr.Close()
الرد }}}
تم الشكر بواسطة:
#3
(15-09-17, 02:15 PM)0theghost0 كتب : السلام عليكم

أريد كود يقوم بإعادة الترقيم داخل القاعدة البيانات اذا كانت AutoNumber
القاعدة البيانات نوع Access
مثال بسيط :
1 - احمد
2 - علي

بعد عملية الحذف والاضافة مجددا يصبح :
1- احمد
3- علي

اريد كود يقوم بالترتيب الارقام من جديد

الرابط
الرد }}}
تم الشكر بواسطة:
#4
كود :
System.InvalidCastException occurred
 HResult=0x80004002
 Message=Unable to cast object of type 'System.Data.OleDb.OleDbConnection' to type 'System.Data.SqlClient.SqlConnection'.
 Source=autonumber
 StackTrace:
  at autonumber.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\TheGhost\Documents\Visual Studio 2017\Projects\autonumber\autonumber\Form1.vb:line 7
  at System.Windows.Forms.Control.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at System.Windows.Forms.Button.WndProc(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
  at autonumber.My.MyApplication.Main(String[] Args) in :line 81


وين الخلل
كود :
Imports System.Data.SqlClient

Public Class Form1
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim s As String = "1"
       Dim a As String = "select isnull(max(Cus_ID),0) from Customer"
       Dim comman As New SqlCommand(a, conn)
       conn.Open()

       Dim readr As SqlDataReader = comman.ExecuteReader
       If readr.Read Then
           s = readr.Item(0) + 1
           TextBox1.Text = s

       End If
       conn.Close()
       readr.Close()
   End Sub
End Class
الرد }}}
تم الشكر بواسطة:
#5
(26-09-17, 09:36 AM)0theghost0 كتب :
كود :
System.InvalidCastException occurred
 HResult=0x80004002
 Message=Unable to cast object of type 'System.Data.OleDb.OleDbConnection' to type 'System.Data.SqlClient.SqlConnection'.
 Source=autonumber
 StackTrace:
  at autonumber.Form1.Button1_Click(Object sender, EventArgs e) in C:\Users\TheGhost\Documents\Visual Studio 2017\Projects\autonumber\autonumber\Form1.vb:line 7
  at System.Windows.Forms.Control.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnClick(EventArgs e)
  at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
  at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.ButtonBase.WndProc(Message& m)
  at System.Windows.Forms.Button.WndProc(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
  at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
  at autonumber.My.MyApplication.Main(String[] Args) in :line 81


وين الخلل
كود :
Imports System.Data.SqlClient

Public Class Form1
   Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Dim s As String = "1"
       Dim a As String = "select isnull(max(Cus_ID),0) from Customer"
       Dim comman As New SqlCommand(a, conn)
       conn.Open()

       Dim readr As SqlDataReader = comman.ExecuteReader
       If readr.Read Then
           s = readr.Item(0) + 1
           TextBox1.Text = s

       End If
       conn.Close()
       readr.Close()
   End Sub
End Class

اخي الكريم لقد تذكرت اني وضعت موضوع حول هذا 
http://vb4arb.com/vb/showthread.php?tid=2073
لا اكتب شيئا الا وقد جربته
الرد }}}
تم الشكر بواسطة:


المواضيع المحتمل أن تكون متشابهة .
الموضوع : الكاتب الردود : المشاهدات : آخر رد
  محتاج طريقة لتنسيق نص الرسالة المرسلة إلى الواتس اب new_programer 2 152 04-03-24, 07:15 AM
آخر رد: new_programer
  محتاج تشفير فيديو وتشغلية عن طريق البرنامج فقط new_programer 1 103 22-02-24, 12:09 PM
آخر رد: AHMED213
  [سؤال] مشكله كود TRansaction وحقل الترقيم التلقائي 01AHMED 0 107 09-02-24, 10:31 PM
آخر رد: 01AHMED
  [VB.NET] محتاج كود حساب الفرق بين تاريخين بالايام moustafakamel95 3 438 29-01-24, 04:05 PM
آخر رد: مصطفى مصطفى
  الترقيم التلقائي محمد خيري 4 297 20-01-24, 03:12 AM
آخر رد: محمد خيري
  احتاج كود اعادة الترقيم في السنة الجديدة ranosh 3 454 27-11-23, 01:25 AM
آخر رد: justforit
  [VB.NET] كيف يمكنني إعداد ترقيم تلقائي ويتجدد الترقيم في كل يوم Osama_NY 8 2,752 04-11-23, 01:42 PM
آخر رد: الحزين اليماني
  مساعدة في الترقيم التلقائي foad8920 1 383 13-10-23, 08:21 PM
آخر رد: aljzazy
  [VB.NET] محتاج مساعدة تعديل على كود ZEEN4ZEEN 4 415 08-10-23, 09:11 PM
آخر رد: ZEEN4ZEEN
  محتاج تعديل على سورس كود - حفظ البيانات بدون قاعدة بيانات new_programer 5 618 30-08-23, 12:21 AM
آخر رد: atefkhalf2004

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم