Jump to content

[ SQL ] connection SQL


Recommended Posts

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

مشكلة ثانية

        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

 

Link to comment
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?

وش اللغه

Link to comment
            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();
            }

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

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

Link to comment

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...