Jump to content

[ SQL ] connection SQL


Recommended Posts

Posted
        SqlConnection cn = new SqlConnection(@"Data source=Talis-PC\Talis; Initial Catalog=MyDataBase; Integrated Security=true;");

Error :  ENC0041 Modifying the initializer of 'field' in a partial type will prevent the debug session from continuing.
 

Posted

تم حل المشكلة اللي فوق ^ 

مشكلة ثانية

        SqlConnection cn = new SqlConnection(@"Server=.\Talis; DataBase=MyDataBase; Integrated Security=true;");
        SqlCommand cmd;
        SqlDataReader dr;
        public Form1()
        {
            InitializeComponent();
            cmd = new SqlCommand("Selcet Title From Table_Books", cn);
            cn.Open();
            dr = cmd.ExecuteReader();
           while (dr.Read())
            {
                listBox1.Items.Add(dr["Title"].ToString());
            }
            dr.Close();
            cn.Close();
  
  

 9في سطر 

System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'From'.'

@iMr.WiFi..!

@Master_MTA

@#,+( _xiRoc[K]; >

@Abdul KariM

 

Posted
3 minutes ago, Talis said:

تم حل المشكلة اللي فوق ^ 

مشكلة ثانية


        SqlConnection cn = new SqlConnection(@"Server=.\Talis; DataBase=MyDataBase; Integrated Security=true;");
        SqlCommand cmd;
        SqlDataReader dr;
        public Form1()
        {
            InitializeComponent();
            cmd = new SqlCommand("Selcet Title From Table_Books", cn);
            cn.Open();
            dr = cmd.ExecuteReader();
           while (dr.Read())
            {
                listBox1.Items.Add(dr["Title"].ToString());
            }
            dr.Close();
            cn.Close();
  
  

 9في سطر 

System.Data.SqlClient.SqlException: 'Incorrect syntax near the keyword 'From'.'

@iMr.WiFi..!

@Master_MTA

@#,+( _xiRoc[K]; >

@Abdul KariM

 

اذكر اللغه اللي مستخدمه هل هي c#

?

java?

وش اللغه

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
37 minutes ago, Talis said:

C#

الخطا اللي معطينا اياه ماله علاقه بالكود على حسب ظني؟

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
25 minutes ago, Master_MTA said:

الخطا اللي معطينا اياه ماله علاقه بالكود على حسب ظني؟

مدري والله ، اذا جيت اسوي ستارت يعطيني خطا في سطر 9

Posted
10 minutes ago, Talis said:

مدري والله ، اذا جيت اسوي ستارت يعطيني خطا في سطر 9

  1. cn.Open();؟

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
27 minutes ago, Talis said:

سطر 10 * اعذرني

يتعدل الى

            cmd = new SqlCommand(cn,"Selcet Title From Table_Books");

 

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
1 minute ago, Talis said:

hmmm

حسبت مثل لوا المهم 

جرب كذا


            cmd = new SqlCommand("Selcet Title From Table_Books", new SqlConnection(@"Server=.\Talis; DataBase=MyDataBase; Integrated Security=true;"));

 

  • Like 1

Skype 01100001 01101100 01101001 01011111 01101101 01110100 00110001 00111001 00111001 00111001

every thing is gonna be alright

every thing is gonna be okay

it's gonna be a good good life

that's what my therapist say

Posted
12 minutes ago, #,+( _xiRoc[K]; > said:

Selcet = Select

الله يرزقك الجنة

ياخي من امس وانا احاول 

خطأ بسيط خرب البرنامج بالكامل هههههه

الله يعطيكم العافية 

  • Like 1
Posted
            try
            {

                cmd = new SqlCommand("Insert into Table_Books(ID, Title, Auther, Date, Pages) values ('" + textID.Text + "', '" + textTitle.Text + "', '" + textAuther.Text + "', '" + DataTimef.Value + "'. '" + Textofpages.Text + "')", cn);
                cn.Open();
                cmd.BeginExecuteNonQuery();
                MessageBox.Show("added successfully !", "add", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (SqlException ex)
            {
                MessageBox.Show("some errors in your code " + ex.Message);
            }
            finally
            {
                cn.Close();
            }

ليه مايضيف شي بالجدول؟

مافي اي خطأ في الليست +

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...