在windows程序中调用存储过程的问题
我用的是VS2005和自带的sql2005   
 我调用存储过程将一条记录写入数据库,VS下直接运行存储过程可以在数据库中永久插入记录,在程序运行时也调用相同的存储过程插入记录了可以显示出来,但关闭程序发现数据库中没有添加任何记录。 
 程序我是这么写的 
                         public   bool   InsertPriority(ref   SqlConnection   myConn,string   newPriority) 
                         { 
                                     SqlCommand   cmd   =   new   SqlCommand( "InsertPriority ",   myConn); 
                                     cmd.CommandType   =   CommandType.StoredProcedure; 
                                     SqlParameter   p   =   new   SqlParameter( "@PriorityTitle ",   newPriority); 
                                     cmd.Parameters.Add(p); 
                                     try 
                                     { 
                                                 cmd.ExecuteNonQuery(); 
                                     } 
                                     catch 
                                     { 
                                                 return   false; 
                                     } 
                                     return   true; 
                         }   
 请大家帮帮忙,这个问题困扰我好几天了
------解决方案--------------------newPriority有没有赋值啊
------解决方案--------------------呵呵  你试试插入数据后  重新连接数据库看看有结果嘛??  一般在程序里显示出来了 说明数据库有数据了
------解决方案--------------------你在SqlParameter p = new SqlParameter( "@PriorityTitle ", newPriority);后面加上   
 p.Direction = ParameterDirection.Input;   
 试试。
------解决方案--------------------SqlParameter param = new SqlParameter( "@PriorityTitle ", SqlDbType.VarChar, 20); 
 param.Value = newPriority; 
 p.Direction = ParameterDirection.Input;   
 可能是LZ在实例化参数的时候没有指定参数大小 和类型
------解决方案--------------------public bool InsertPriority(ref SqlConnection myConn,string newPriority) 
         { 
             SqlCommand cmd = new SqlCommand( "InsertPriority ", myConn); 
             cmd.CommandType = CommandType.StoredProcedure; 
             SqlParameter p = new SqlParameter( "@PriorityTitle ", newPriority); 
             cmd.Parameters.Add(p); 
             try 
             { 
                 cmd.ExecuteNonQuery(); 
             } 
             catch 
             { 
                 return false; 
             } 
             return true; 
         }     
 --------------------------   
 你这样可以是没有执行cmd.ExecuteNonQuery();   
 试下 
         public bool InsertPriority(ref SqlConnection myConn,string newPriority)