עבור לתוכן
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.

הכנסת שורה בטבלה ב- DB ב- C#

Featured Replies

פורסם

שלום,

יצרתי DATABASE מקומי ריק. יצרתי טבלה. אני רוצה להכניס שורה דרך הקוד. הרצתי קוד השורה הוכנסה אך אני לא רואה את השורה בטבלה. זה כאילו הנתונים

שהכנסתי לא נשמרו. מה לא עשיתי נכון?

זה הקוד שהרצתי:

SqlConnection cn = new SqlConnection(CaloriesCalculator.Properties.Settings.Default.myDatabaseConnectionString);
try
{

string sql = "INSERT INTO Foods(id,name,amount,calories) VALUES(2003,'a','b',22)";
SqlCommand mySqlCommand = new SqlCommand(sql, cn);
cn.Open();
int m = mySqlCommand.ExecuteNonQuery();
id++;
MessageBox.Show(m.ToString());

}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "erorr");
}


cn.Close();

פורסם
  • מחבר

מישהו?

  • 2 שבועות מאוחר יותר...
פורסם

לא ממש מבין מה ניסית לעשות, קודם תריץ את התוספת ב SQL תראה עם היא עובדת, אח"כ תייסם בקוד

  • 3 שבועות מאוחר יותר...
פורסם

1. תבדוק שאתה מחובר ל DATABASE הנכון - נסה לשלוף נתונים ולקל את אלו שאתה מצפה (תעשה שינוי בטבלה עצמה כדי להיות בטוח שאתה במקום הרלוונטי)

2. תבדוק שהפקודת SQL רצה ידנית (כמו מה שמי שמעליי כתב)

3. אולי יש הגדרה של ה CONNECITON שאומרת לו שזה לקריאה בלבד - או שלמתשמש יש הרשאות כאלה - אבל לא נראה לי כי בטח הייתי מקבל הודעת שגיאה

אבל בעיקר סעיף 1 :-)

  • 3 שבועות מאוחר יותר...
פורסם

באיזה סוג DB אתה משתמש? SQL SERVER או MYSQL ?

כי אתה יצרת אובייקט התחברות של SQL SERVER ו פקודה בMYSQL

ארכיון

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

דיונים חדשים

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.