| |

VerySource

 Forgot password?
 Register
Search
View: 4199|Reply: 30

Executing the stored procedure has no effect, but no error is reported, but the stored procedure executes normally in th

[Copy link]

1

Threads

60

Posts

37.00

Credits

Newbie

Rank: 1

Credits
37.00

 China

Post time: 2020-1-31 09:40:01
| Show all posts |Read mode
public void JiSuanZongHe (string faid, string bjid, string xsid)
        {
            string connectionString = ConfigurationSettings.AppSettings ["CrmSqlConnect"];
            string error = "";
            SqlConnection m_conn = new SqlConnection (connectionString);
            m_conn.Open ();
            SqlCommand m_com = new SqlCommand ("P_JISUAN_ZHCJ '" + faid + "', '" + bjid + "', '" + xsid + "', '" + error + "'", m_conn);
            m_com.CommandType = CommandType.Text;


            m_com.ExecuteNonQuery ();
            m_conn.Close ();


        }
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-10 19:15:01
| Show all posts
Maybe Command, I just learned, you look at mine, this
public void ExeuteNoQuery (string proc, SqlParameter [] paramlist)
    {
        SqlConnection conn = new SqlConnection (ConfigurationManager.ConnectionStrings ["AdsysConnectionString"]. ConnectionString);
        conn.Open ();
        SqlCommand cmd = new SqlCommand ();
        cmd.Connection = conn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = proc;

        if (paramlist! = null&&paramlist.Length> 0)
        {
            foreach (SqlParameter param in paramlist)
            {
                cmd.Parameters.Add (param);
            }
        }
        cmd.ExecuteNonQuery ();
        conn.Close ();

    }

Write a method in the entity class. Call this method and pass the parameter list and stored procedure name. !
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-10 22:30:01
| Show all posts
You wrote it wrong
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-10 23:30:02
| Show all posts
cmd.CommandType = CommandType.StoredProcedure;
Reply

Use magic Report

0

Threads

29

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-3-11 13:30:01
| Show all posts
("P_JISUAN_ZHCJ '" + faid + "', '" + bjid + "', '" + xsid + "', '" + error + "'",)
Is there a problem with string concatenation ..
Reply

Use magic Report

0

Threads

29

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-3-11 19:45:02
| Show all posts
Don't write faid, bjid, xsid parameters are all changed to characters, your parameters should be integers.
When SQL is executed. Are the parameters all strings? Similar:
exec P_JISUAN_ZHCJ 'faid', 'bjid', 'error'
Reply

Use magic Report

1

Threads

60

Posts

37.00

Credits

Newbie

Rank: 1

Credits
37.00

 China

 Author| Post time: 2020-3-12 11:00:02
| Show all posts
Not P_JISUAN_ZHCJ is the name of the stored procedure

'"+ faid +"' is a string
Reply

Use magic Report

0

Threads

29

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 China

Post time: 2020-3-12 16:00:01
| Show all posts
I know, do you mean that none of your parameters are integers? They are all character types?
Reply

Use magic Report

0

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-12 18:45:01
| Show all posts
Is this wrong? M_com.CommandType = CommandType.Text;
Should it be written like this: cmd.CommandType = CommandType.StoredProcedure;
Reply

Use magic Report

1

Threads

60

Posts

37.00

Credits

Newbie

Rank: 1

Credits
37.00

 China

 Author| Post time: 2020-3-12 21:00:01
| Show all posts
Yes, they are all character
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list