עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

הוספת DataRow חדש עם id ב- C#

Featured Replies

פורסם

אני בונה תוכנה ב- C# שתתחבר למסד נתונים SQL Server 2005 Express ותעבוד איתו (הוספה, עידכון, מחיקה וכו').

נתקלתי בבעיה עם הוספת שורה חדשה לטבלה.

כשאני מוסיף שורה חדשה ככה:

DataRow newRow = DataTable.NewRow();
newRow["name"] = name;
newRow["street"] = street;
newRow["no"] = no;
newRow["city"] = city;
newRow["tel1"] = tel1;
newRow["tel2"] = tel2;
DataTable.Rows.Add(newRow);
DataAdapter.Update(DataTable);

ה- id לא נוסף לי אוטומטית (למרות שהוא אמור כי הוא מספור אוטומטי).

כל עוד התוכנה פועלת לא ניתן לדעת מה ה- id של השורה.

פיזית, כשאני סוגר את התוכנה ונכנס אל הטבלה בעזרת SQL Management Tools אני רואה שה- id כן נוסף וגם כשאני מפעיל את התוכנה מחדש אני רואה את השורות החדשות עם ה- id אבל לא באותו מהלך של התוכנה.

איך אני יכול לטפל בבעיה הזאת?

פורסם

בעצם,

הבעיה שלך היא לא הוספת השורה (כי אמרת שזה בעצם עובד טוב)

הבעיה שלך זה שאתה לא יודע מה ה-Id של השורה החדשה שהוספת?

פורסם
  • מחבר

כן, אני לא יודע איך לקבל את זה, וזה גם לא עושה את זה אוטומטית.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.