الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

طريقه ربط برنامجي مع قاعده البيانات

مغلق
بدأه c++2003 في 27 يونيو 2004 · 2 رد · 760 مشاهدة · في قسم تكنولوجيا Microsoft .NET العام
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

قمت بعمل برنامج بلغه سي شارب يقوم بتنفيذ storedprocedure التالي

create PROCEDURE dbo.abdullah

AS

declare @num int

select @num=max(CategoryID)

from Categories

return @num

البرنامج هو

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

namespace WindowsApplication34

{

public class Form1 : System.Windows.Forms.Form

{

private System.Data.SqlClient.SqlConnection Cn;

private System.Data.SqlClient.SqlCommand Cmd;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.TextBox textBox1;

private System.ComponentModel.Container components = null;

public Form1()

{

InitializeComponent();

}

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows Form Designer generated code

private void InitializeComponent()

{

this.Cn = new System.Data.SqlClient.SqlConnection();

this.Cmd = new System.Data.SqlClient.SqlCommand();

this.button1 = new System.Windows.Forms.Button();

this.textBox1 = new System.Windows.Forms.TextBox();

this.SuspendLayout();

//

// Cn

//

this.Cn.ConnectionString = "workstation id=FF;packet size=4096;integrated security=SSPI;data source=ff;persis" +

"t security info=False;initial catalog=northwind";

//

// Cmd

//

this.Cmd.CommandText = "dbo.[abdullah]";

this.Cmd.Connection = this.Cn;

this.Cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(0)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));

//

// button1

//

this.button1.Location = new System.Drawing.Point(96, 40);

this.button1.Name = "button1";

this.button1.TabIndex = 0;

this.button1.Text = "button1";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(88, 16);

this.textBox1.Name = "textBox1";

this.textBox1.TabIndex = 1;

this.textBox1.Text = "textBox1";

//

// Form1

//

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.button1);

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

[sTAThread]

static void Main()

{

Application.Run(new Form1());

}

private void button1_Click(object sender, System.EventArgs e)

{

Cn.Open();

textBox1.Text=Cmd.ExecuteScalar().ToString();

Cn.Close();

}

}

}

object refernce not set to an instance of an objectعند تنفيذ البرنامج يظهر الخطاء التالي

abdullahf4.jpg
#2

؟؟Which line exactly fire the error

رأس الحكمة الإيمان بالله

#3

يا c++ 2003

اولاً : المكان غير مناسب لان تضع مشكلتك فيه وكان من الاولى وضعها فى منتدى

السى شارب

ثانياً: الافضل ان تضع المشروع كله كملف مرفق مع تحديد الاصداره التى تستخدمها و نظام التشغيل

تم تعديل هذه المشاركة بواسطة طارق إبراهيم في 27 يونيو 2004 في 03:07

Technical Lead Developer

My LinkedIn Profile

اللهم قنى شر الجهل و الجهلاء

( اقْتَرَبَ لِلنَّاسِ حِسَابُهُمْ وَهُمْ فِي غَفْلَةٍ مَّعْرِضُونَ ) {الأنبياء:1}

هذا الموضوع مغلق.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…